3799. Unique 3-Digit Even Numbers
My accepted Python solution to LeetCode problem 3799, Unique 3-Digit Even Numbers, running in 16ms.
- Difficulty: Easy
- Python
- Runtime 16ms
- Memory 17.1MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 16ms, memory 17.1MB, accepted 2025-12-31.
class Solution:
def totalNumbers(self, digits: List[int]) -> int:
from itertools import permutations
result = set()
for perm in permutations(digits, 3):
if perm[0] != 0 and perm[2] % 2 == 0: # no leading zero, last digit even
num = perm[0] * 100 + perm[1] * 10 + perm[2]
result.add(num)
return len(result)