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
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
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code