LeetCode solutions

2668. Form Smallest Number From Two Digit Arrays

My accepted Python solution to LeetCode problem 2668, Form Smallest Number From Two Digit Arrays, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2026-01-01.

python
class Solution:
    def minNumber(self, nums1: List[int], nums2: List[int]) -> int:
        # Check for common digit
        common = set(nums1) & set(nums2)
        if common:
            return min(common)
        
        # No common digit, form smallest two-digit number
        min1 = min(nums1)
        min2 = min(nums2)
        
        # Form the smallest number with these two digits
        if min1 < min2:
            return min1 * 10 + min2
        else:
            return min2 * 10 + min1

Source