You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1.
3
+
4
+
Note that an integer is said to be common to nums1 and nums2 if both arrays have at least one occurrence of that integer.
5
+
6
+
7
+
8
+
Example 1:
9
+
10
+
Input: nums1 = [1,2,3], nums2 = [2,4]
11
+
Output: 2
12
+
Explanation: The smallest element common to both arrays is 2, so we return 2.
13
+
Example 2:
14
+
15
+
Input: nums1 = [1,2,3,6], nums2 = [2,3,4,5]
16
+
Output: 2
17
+
Explanation: There are two common elements in the array 2 and 3 out of which 2 is the smallest, so 2 is returned.
18
+
19
+
20
+
Constraints:
21
+
22
+
1 <= nums1.length, nums2.length <= 105
23
+
1 <= nums1[i], nums2[j] <= 109
24
+
Both nums1 and nums2 are sorted in non-decreasing order.
0 commit comments