2283. Check if Number Has Equal Digit Count and Digit Value

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2283

class Solution:
    def digitCount(self, num: str) -> bool:
        cnt = Counter(num)
        return all(cnt[str(i)] == int(v) for i, v in enumerate(num))