[Python 3] Using Counter fast solution + One-Liner
Approach: Create a dict storing frequency of each number and then just compare the index with frequency.\n\n\nfrom collections import Counter\n\nclass Solution:
Approach: Create a dict storing frequency of each number and then just compare the index with frequency.\n\n```\nfrom collections import Counter\n\nclass Solution:\n    def digitCount(self, num: str) -> bool:\n        d = Counter(num)\n        for i in range(len(num)):\n            if int(num[i])!=d.get(str(i), 0):\n                return False\n        return True\n```\n\nTwo-Liner:\n\n```\n\nclass Solution:\n    def digitCount(self, num: str) -> bool:\n        d = collections.Counter(num)\n        return all([int(num[i])==d.get(str(i), 0) for i in range(len(num))])\n```\n\nOne Liner (slight modification):\n\n```\n\nclass Solution:\n    def digitCount(self, num: str) -> bool:\n        return all([int(num[i])==Counter(num)[f\'{i}\'] for i in range(len(num))])\n```
['Python']