Swift Solution
\nclass Solution {\n    func digitCount(_ num: String) -> Bool {\n        var dict: [Int: Int] = [:]\n        for ch in num { \n            dict[Int(String(ch))
```\nclass Solution {\n    func digitCount(_ num: String) -> Bool {\n        var dict: [Int: Int] = [:]\n        for ch in num { \n            dict[Int(String(ch))!, default: 0] += 1\n        }\n        let n = num.count\n        let nums = Array(num)\n        for i in 0..<n { \n            let num = Int(String(nums[i]))!\n            if (dict[i, default: 0] != num) { return false }\n        }\n        return true\n    }\n}\n```
['Swift']