Ctrl K

Only on One Side

Easy
You get two integer arrays first and second. Return a list of two lists: - the first holds every distinct number of first that does not appear in second; - the second holds every distinct number of second that does not appear in first. Each number appears at most once in the answer. The order of numbers inside each list does not matter.
Example 1
first=[4, 8, 15, 8], second=[15, 16, 23] → [[8, 4], [16, 23]]

Only the first array has 4 and 8 (the 8 counts once), only the second has 16 and 23. The 15 is in both.

Example 2
first=[-2, 0], second=[0, -2, -2] → [[], []]

Both arrays hold the same set of values, so both lists are empty.

Constraints
  • 0 ≤ len(first), len(second) ≤ 10⁵
  • -1000 ≤ first[i], second[i] ≤ 1000
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
first=[4, 8, 15, 8], second=[15, 16, 23]
Expected
[[8, 4], [16, 23]]

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