💯Best Approach,Easy to UnderStand
Code\n\nvar digitCount = function (num) {\n    let arr = num.split(\'\').map(Number)\n    let freq = {}\n    for (let j = 0; j < arr.length; j++) {\n        let
# Code\n```\nvar digitCount = function (num) {\n    let arr = num.split(\'\').map(Number)\n    let freq = {}\n    for (let j = 0; j < arr.length; j++) {\n        let number = arr[j]\n        if (!freq[number]) {\n            freq[number] = 1\n        } else {\n            freq[number] = freq[number] + 1\n        }\n    }\n    for (let i = 0; i < arr.length; i++) {\n        if ((freq[i] || 0) !== arr[i]) {\n            return false\n        }\n    }\n    return true\n}\n```
['JavaScript']