Easy hash map solution with O(n). 100% 0ms
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nHash map\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nHash map\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```javascript []\n/**\n * @param {string} num\n * @return {boolean}\n */\nvar digitCount = function(num) {\n    let map = {}\n    for(let char of num) {\n        if(map[char]) map[char]++\n        else map[char] = 1\n    }\n    \n    for(let i = 0; i < num.length; i++) {\n        if(!map[i] && num[i] == 0) continue\n        if(map[i] != num[i]) return false\n    }\n    return true\n};\n```
['JavaScript']