Easy solution//begiiner friendly
Intuition\n Describe your first thoughts on how to solve this problem. \ncount the occurance of index in the string\n\n# Approach\n Describe your approach to so
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncount the occurance of index in the string\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nwe will count the number of occurance index from counts method, like 1201, 1 is occured 2 times, and we will match that count with the character at that index; if it is not equal we will return false \n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public boolean digitCount(String num) {\n        for(int i=0;i<num.length();i++){\n            int count = counts(num,i);\n            if((char)(count+\'0\')!=num.charAt(i)) return false;\n    }\n    return true;\n}\n public int counts(String s, int x){\n        int count = 0;\n        char c = (char)(x+\'0\');\n        for(int i=0;i<s.length();i++){\n            if(s.charAt(i)== c) count++;\n        }\n        return count;\n    }\n}\n```
['Java']