Ctrl K

Values Found in Both Lists

Easy
You are given two integer lists, left and right. Compute two numbers: - how many elements of left (repeats counted) occur somewhere in right; - how many elements of right (repeats counted) occur somewhere in left. Return them as a pair [first, second].
Example 1
left=[4, 7, 4, 1], right=[4, 9, 7] → [3, 2]

In left, the elements 4, 7 and 4 also occur in right: that is 3. In right, 4 and 7 occur in left: that is 2.

Example 2
left=[2, 2], right=[2, 2, 2] → [2, 3]

Every element of each list occurs in the other one.

Example 3
left=[1, 3], right=[5] → [0, 0]
Constraints
  • 1 ≤ len(left), len(right) ≤ 100
  • 1 ≤ left[i], right[i] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasyThe Candidate With Most Votes EasyDoes Any Value Repeat EasyRepeat Within Reach EasyThe Lost Ticket Easy
loading Python…
Input
left=[4, 7, 4, 1], right=[4, 9, 7]
Expected
[3, 2]

Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.