Skip to content

Practice Minimum Common Value

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2540
LeetCode Problem

Minimum Common Value

Problem Statement

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. Note that an integer is said to be common to nums1 and nums2 if both arrays have at least one occurrence of that integer.

Source: Minimum Common Value on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums1 = [1,2,3], nums2 = [2,4]
Output
2

# Example 2

Input
nums1 = [1,2,3,6], nums2 = [2,3,4,5]
Output
2

Constraints

1 <= nums1.length, nums2.length <= 10^5
1 <= nums1[i], nums2[j] <= 10^9
Both nums1 and nums2 are sorted in non-decreasing order.

Related LeetCode Problems

Practice more problems similar to Minimum Common Value.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.