You are given an array of digits called digits. Your task is to determine the number of distinct three-digit even numbers that can be formed using these digits. Note: Each copy of a digit can only be used once per number, and there may not be leading zeros.
Example 1
Input: digits = [1,2,3,4]
Output: 12
Explanation: The 12 distinct even 3-digit numbers are 124, 132, 134, 142, 214, 234, 312, 314, 324, 342, 412, 432. 222 is impossible since 2 appears only once.
Example 2
Input: digits = [0,2,2]
Output: 2
Explanation: Only 202 and 220; the two copies of 2 are interchangeable so each number is counted once.
Example 3
Input: digits = [6,6,6]
Output: 1
Explanation: Only 666 can be formed.
The array has at most 10 digits, so there are at most 10 x 9 x 8 = 720 ways to pick an ordered triple of positions; enumerate them all, keep the ones that form a valid even number with no leading zero, and use a set to drop duplicates.
Run checks all cases above. Submit evaluates all test cases.