LeetCode solutions

2634. Minimum Common Value

My accepted Python solution to LeetCode problem 2634, Minimum Common Value, running in 11ms.

  • Difficulty: Easy
  • Python
  • Runtime 11ms
  • Memory 33MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 11ms, memory 33MB, accepted 2026-01-01.

python
class Solution:
    def getCommon(self, nums1: List[int], nums2: List[int]) -> int:
        i, j = 0, 0
        while i < len(nums1) and j < len(nums2):
            if nums1[i] == nums2[j]:
                return nums1[i]
            elif nums1[i] < nums2[j]:
                i += 1
            else:
                j += 1
        return -1

Source