C++ | Easy Solution using Unordered Maps
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nbool digitCount(string num) {\n    unordered_map<int,int> um;\n    for(int i = 0; i < num.length(); i++)\n    {\n        int x = int(num[i] - \'0\');\n        um[x]++;\n    }\n\n    for(int i = 0; i < num.length(); i++)\n    {\n        int n = int(num[i] - \'0\');\n        if(um.find(i) != um.end())\n        {\n            if(um[i] != n)\n                return false;\n        }\n        else\n        {\n            if(n != 0)\n                return false;\n        }\n    }\n    return true;\n}\n```
['Hash Table', 'C++']