Java | HashMap | String | Straightforward Solution
\nclass Solution {\n    public boolean digitCount(String num) {\n        HashMap<Integer,Integer> map = new HashMap<>();\n        for(int i=0;i<num.length();i++
```\nclass Solution {\n    public boolean digitCount(String num) {\n        HashMap<Integer,Integer> map = new HashMap<>();\n        for(int i=0;i<num.length();i++){\n            int n = Character.getNumericValue(num.charAt(i));\n            map.put(n,map.getOrDefault(n,0)+1);\n        }\n        for(int i=0;i<num.length();i++){\n            if(map.containsKey(i)){\n                int nn = map.get(i);\n                if(nn!=Character.getNumericValue(num.charAt(i)))\n                    return false;\n            }\n            else{\n                if(Character.getNumericValue(num.charAt(i))>0)\n                    return false;\n            }\n        }\n        return true;\n    }\n}\n```\nKindly upvote if you like the code.
['String', 'Counting', 'Java']