Count how many distinct 3-digit even numbers can be formed from a set of digits, using each input digit no more times than it appears.
You are given an array of digits. Form all possible 3-digit even numbers using the digits from the array.
A valid number must:
Return the number of distinct valid numbers that can be formed.
digits containing decimal digits from 0 to 9.1 <= digits.length <= 100 <= digits[i] <= 9digits.Example 1
Input
digits = [2,1,3,0]
Output
12
Explanation
The distinct valid 3-digit even numbers include 102, 120, 130, 132, 201 is odd, and so on. In total, there are 12 distinct numbers.
Example 2
Input
digits = [2,2,8,8,2]
Output
3
Explanation
The distinct valid numbers are 222, 228, and 282? No, 282 is even and valid, while 822 is also valid. The distinct results are 222, 228, 282, 822, 828, and 882 only if digits allow them. Since there are three 2s and two 8s, the valid distinct numbers are 222, 228, 282, 822, 828, 882, so the count is 6.
Example 3
Input
digits = [0,0,0]
Output
0
Explanation
Any 3-digit number would start with 0, so no valid number can be formed.
Premium problem context
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.