O(n) solution using MAP
\nclass Solution {\npublic:\n    bool digitCount(string num) {\n        map<int,int> m;\n        int n=num.size();\n        for(int i=0;i<n;i++){\n            m
```\nclass Solution {\npublic:\n    bool digitCount(string num) {\n        map<int,int> m;\n        int n=num.size();\n        for(int i=0;i<n;i++){\n            m[num[i]-\'0\']++;\n        }\n        for(int i=0;i<n;i++ ){\n            if(num[i]==\'0\'&&m.find(i)==m.end())continue;\n            if(m.find(i)!=m.end()&&m[i]==(num[i]-\'0\'))continue;\n            return false;\n        }\n        return true;\n    }\n};\n```
['String']