Back to course home
0% completed
Solution: Minimum Common Value
Problem Statement
Given two sorted arrays nums1
and nums2
containing integers only, return the smallest integer that appears in both arrays. If there isn't any integer that exists in both arrays, the function should return -1.
Examples
Example 1:
- input: nums1 = [1, 3, 5, 7], nums2 = [3, 4, 5, 6, 8, 10]
- expectedOutput: 3
- Justification: Both arrays share the integers 3 and 5, but the smallest common integer is 3.
Example 2:
- input: nums1 = [2, 4, 6], nums2 = [1, 3, 5]
- expectedOutput: -1
.....
.....
.....
Like the course? Get enrolled and start learning!