Unique 3-Digit Even Numbers

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
Inputdigits = [1,2,3,4]
Output12
The 12 distinct 3-digit even numbers that can be formed are 124, 132, 134, 142, 214, 234, 312, 314, 324, 342, 412, and 432; 222 cannot be formed because there is only 1 copy of the digit 2.
Example 2
Inputdigits = [0,2,2]
Output2
The only 3-digit even numbers that can be formed are 202 and 220; the digit 2 can be used twice because it appears twice in the array.

Constraints

  • 3 <= digits.length <= 10
  • 0 <= digits[i] <= 9

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate