Easy understanding hash java 99.85%beats code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public boolean digitCount(String num) {\n        HashMap<Integer,Integer> map=new HashMap<>();\n\n        for(int i=0;i<num.length();i++){\n            int ch=num.charAt(i)-\'0\';\n            map.put(ch,map.getOrDefault(ch,0)+1);\n        }\n        // StringBuilder sb=new StringBuilder();\n        int count=0;\n        for(int i=0;i<num.length();i++){\n\n            if(map.containsKey(i)){\n                count=map.get(i);\n            }\n            else{\n                count=0;\n            }\n          int x=num.charAt(i)-\'0\';\n            if(x!=count){\n                return false;\n            }\n        }\n      return true;\n    }\n}\n```
['Java']