Difference of Two Arrays
EasyP3Coding
Given two integer arrays nums1 and nums2, return a list of two lists:
- the distinct values that appear in
nums1but not innums2; - the distinct values that appear in
nums2but not innums1.
Sort each inner list in increasing order.
Example 1
- Input
- nums1 = [1,2,3], nums2 = [2,4,6]
- Output
- [[1,3],[4,6]]
Example 2
- Input
- nums1 = [1,2,3,3], nums2 = [1,1,2,2]
- Output
- [[3],[]]
Example 3
- Input
- nums1 = [], nums2 = []
- Output
- [[],[]]
Constraints
- 0 <= nums1.length, nums2.length <= 1000
- -1000 <= nums1[i], nums2[i] <= 1000
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.