Digit Counter
Given a non-negative integer n, count how many times each digit appears in its written form. Return a dictionary where each key is a digit as a string, and each value is the number of times that digit appears. Include only digits that actually occur in the number.
Примеры
Ввод
112233Вывод
{"1": 2, "2": 2, "3": 2}Ввод
0Вывод
{"0": 1}Ввод
1000Вывод
{"0": 3, "1": 1}Нужно реализовать
def digit_frequency(n: int) -> dict:
Теги
hashmapstrings
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaTests12
Visible tests
Skriveni test 7
Skriveni test 8
Skriveni test 9
Skriveni test 10
Skriveni test 11
Skriveni test 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid