C++ Solution || Beginner-Friendly || Beats 100% 💯💯
Intuition\nThe intuition behind solving this problem is to traverse the given number\'s string representation and verify if the count of each digit matches the 
# Intuition\nThe intuition behind solving this problem is to traverse the given number\'s string representation and verify if the count of each digit matches the digit itself, ensuring each digit\'s frequency conforms to its value.\n\n# Approach\n1. Initialize a hash table with a size of 11 to store the count of each digit.\n2. Traverse the string representation of the number and increment the count of each digit in the hash table.\n3. Iterate through the string representation again and compare the count of each digit with the digit itself.\n4. If any count does not match the digit, return false; otherwise, return true.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    bool digitCount(string n) {\n        vector<int> hash(11, 0); // store count of each dig\n        for (int i = 0; i < n.size(); i++) {\n            hash[n[i] - \'0\']++; // inc count of dig\n        }\n        for (int i = 0; i < n.size(); i++) {\n            if (hash[i] != n[i] - \'0\') return false; // check if count matches dig\n        }\n        return true;\n    }\n};\n\n```
['Hash Table', 'String', 'Counting', 'C++']