Easy
Intersection of Two Arrays
Easy
248 submissions
10 coins
+50 XP
Array
Hash Table
Problem Description
Return the distinct values that appear in both `nums1` and `nums2`, in **ascending** order.
**Example 1:**
```
Input: nums1 = [1, 2, 2, 1], nums2 = [2, 2]
Output: [2]
```
**Example 2:**
```
Input: nums1 = [4, 9, 5], nums2 = [9, 4, 9, 8, 4]
Output: [4, 9]
```
**Example 3:**
```
Input: nums1 = [1, 3], nums2 = [2, 4]
Output: []
```
Constraints
- `1 <= nums1.length, nums2.length <= 1000`
- `0 <= nums1[i], nums2[i] <= 1000`
Need help?
Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.
Video Call
Whiteboard
Live Coding
Screen Share