Ctrl K

Even Numbers From Digit Cards

Easy
There are digit cards on a table; their values are given in the array cards, and digits may repeat. Pick any three cards and lay them out in a row in any order to form a three-digit number. We are interested in the numbers that: - do not start with zero; - are even. Each card can be used only once per number, so a digit cannot appear in a number more often than it appears on the table. Return all distinct such numbers in increasing order.
Example 1
cards=[4, 0, 5] → [450, 504, 540]

The even numbers without a leading zero are 450, 504 and 540. 405 is odd, and 045 and 054 start with zero.

Example 2
cards=[6, 6, 1, 6] → [166, 616, 666]

There are three 6s and one 1: 166, 616 and 666. 661 is odd.

Example 3
cards=[9, 1, 7, 3] → []

There is no even digit, so no even number can be made and the answer is empty.

Constraints
  • 3 ≤ cards.length ≤ 10⁴
  • 0 ≤ cards[i] ≤ 9
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsOriginal Array From Two Shifts HardOne-Swap Twin Numbers MediumTwins Within Two Swaps HardThe Candidate With Most Votes EasyDoes Any Value Repeat Easy
loading Python…
Input
cards=[4, 0, 5]
Expected
[450, 504, 540]

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