Trains the technique from
LeetCode 2215Find the Difference of Two ArraysThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Two lists of whole numbers are given, left and right. Either list may hold repeats.
Return a list of two lists. The first holds every value that appears in left but nowhere in right, and the second holds every value that appears in right but nowhere in left. Each value appears once in its list, however often it appeared in the input, and both lists come out in increasing order.
Example 1
The 5 sits in both lists, so it appears in neither answer. That leaves 4 and 6 held only on the left, and 7 only on the right.
Example 2
The only value either list holds is 1, and both hold it, so both answers come out empty however many times it was repeated.
Example 3
The lists share nothing, so each reports its own single value.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def find_difference(left: list[int], right: list[int]) -> list[list[int]]:public List<List<Integer>> findDifference(int[] left, int[] right)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.