Form every distinct 3-digit even number that can be built from the given digits.
Problem
You are given an array of digits. Using each digit at most once per number, form all distinct 3-digit even numbers that can be created from those digits.
A valid number must:
- have exactly 3 digits,
- not start with
0, and - end with an even digit.
Return all valid numbers in ascending order.
Notes
- Two numbers are considered the same if they have the same numeric value, even if formed using different digit positions.
- Each digit in the input array may be reused across different numbers, but not more than once within a single number.
Input Format
- An integer array
digits. - Each element is a single digit from
0to9.
Output Format
- Return a list of all distinct valid 3-digit even numbers in increasing order.
Constraints
1 <= digits.length <= 100 <= digits[i] <= 9- The answer should contain no duplicates.
Example 1
Input
digits = [2,1,3,0]
Output
[102,120,130,132,210,230,302,310,312,320]
Explanation
All distinct 3-digit even numbers that can be built without reusing a digit within the same number are listed in sorted order.
Example 2
Input
digits = [2,2,8,8,2]
Output
[222,228,282,288,822,828,882]
Explanation
Repeated digits may be used if enough copies exist in the input, but duplicates in the output are removed.
Show 1 more example
Example 3
Input
digits = [5,7,9]
Output
[]
Explanation
No 3-digit even number can be formed because there is no even digit for the units place.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.