Problem
You get two integer arrays, nums1 and nums2. Return a list answer of two lists.
answer[0] has the distinct values of nums1 that are not in nums2. answer[1] has the distinct values of nums2 that are not in nums1. Distinct values are values without repeats.
The values in each of the two lists can be in any order.
Example 1
- Input:
- nums1 = [4,2,7,2], nums2 = [7,9,4]
- Output:
- [[2],[9]]
- Explanation:
- The value 2 is only in
nums1, andanswer[0]has it one time. The value 9 is only innums2.
Example 2
- Input:
- nums1 = [1,3,8], nums2 = [2,8,10]
- Output:
- [[1,3],[2,10]]
Example 3
- Input:
- nums1 = [5,5,6], nums2 = [6,5]
- Output:
- [[],[]]
- Explanation:
- Each value is in both arrays, so both lists are empty.
Constraints
- 1 <= nums1.length, nums2.length <= 1000
- -1000 <= nums1[i], nums2[i] <= 1000
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Google
Leetcode 2215. Find the Difference of Two Arrays
Reported May 21, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source