Unique 3-Digit Even Numbers - Problem

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.

Input & Output

Example 1 — Basic Case
$ Input: digits = [2,1,3,0]
Output: 2
💡 Note: Can form: 210 (2×100+1×10+0), 230 (2×100+3×10+0). Both are even 3-digit numbers with no leading zeros.
Example 2 — Multiple Even Digits
$ Input: digits = [2,2,8,8,2]
Output: 3
💡 Note: Can form: 228, 282, 822. All are distinct 3-digit even numbers using available digits.
Example 3 — No Valid Numbers
$ Input: digits = [3,7,5]
Output: 0
💡 Note: All digits are odd, so no 3-digit even numbers can be formed.

Constraints

  • 1 ≤ digits.length ≤ 100
  • 0 ≤ digits[i] ≤ 9

Visualization

Tap to expand
Unique 3-Digit Even Numbers Problem2130Input: digits = [2,1,3,0]Valid 3-Digit Even NumbersMust end in even digit (0,2,4,6,8)Cannot start with 0Use each digit only onceFound: 210, 230Result2Count of unique 3-digit even numbers that can be formed
Understanding the Visualization
1
Input
Array of digits [2,1,3,0]
2
Process
Find all 3-digit even combinations without leading zeros
3
Output
Count of unique valid numbers: 2
Key Takeaway
🎯 Key Insight: Focus on even last digits first, then count valid non-zero first digits and remaining middle digits systematically
Asked in
Google 25 Amazon 18 Microsoft 15 Meta 12
28.5K Views
Medium Frequency
~15 min Avg. Time
856 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen