bumpsoo 2025-05-12 22:03:09 +09:00
parent 5dfd6029bd
commit accdb52aec

View file

@ -0,0 +1,36 @@
# https://leetcode.com/problems/finding-3-digit-even-numbers
from typing import List
class Solution:
def findEvenNumbers(self, digits: List[int]) -> List[int]:
counts = [0] * 10
for digit in digits:
counts[digit] += 1
answer = []
i = 0
while i < 10:
if i == 0 or counts[i] == 0:
i += 1
continue
counts[i] -= 1
j = 0
while j < 10:
if counts[j] == 0:
j += 1
continue
counts[j] -= 1
k = 0
while k < 10:
if counts[k] == 0:
k += 1
continue
if k % 2 == 0:
answer.append(i * 100 + j * 10 + k)
k += 1
counts[j] += 1
j += 1
counts[i] += 1
i += 1
return answer