Ctrl K

Smallest Number From Two Digit Sets

Easy
You are given two sets of distinct nonzero digits, left and right. Find the smallest positive integer whose decimal form contains at least one digit from left and at least one digit from right.
Example 1
left=[6, 2, 8], right=[4, 9] → 24

There is no common digit, so a two-digit number is needed: the smallest digits 2 from left and 4 from right give 24.

Example 2
left=[7, 5, 1], right=[3, 5] → 5

The digit 5 is in both sets, so the single-digit 5 works.

Example 3
left=[9], right=[8] → 89
Constraints
  • 1 ≤ len(left), len(right) ≤ 9
  • 1 ≤ left[i], right[i] ≤ 9
  • Digits within each set are distinct
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThree Addends and a Later Total EasyEven Numbers From Digit Cards EasyEvenly Spaced Triples EasyEven Codes From Digit Cards EasyBalanced Cuts After One Replacement Hard
loading Python…
Input
left=[6, 2, 8], right=[4, 9]
Expected
24

Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.