Example with duplicates
Input
nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output
[4, 9]
Common elements are 4 and 9; duplicates are removed and result is sorted.
Full lesson preview
Return the unique intersection elements of two arrays as a sorted list.
Problem statement
Task
Examples
Input
nums1 = [4,9,5], nums2 = [9,4,9,8,4]
Output
[4, 9]
Common elements are 4 and 9; duplicates are removed and result is sorted.
Input format
Output format
Constraints
Samples
Input
intersection_sorted([1,2,2,1], [2,2])
Output
[2]
2 is the only common element; duplicates removed.