Simple java code 1 ms beats 85 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int count(char arr[],int n,char key){\n        int c=0;\n        for(int i=0;i<n;i++){\n           
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/6ae867e3-9fa8-470a-9c30-12ca05b278d4_1703985766.4314551.png)\n# Code\n```\nclass Solution {\n    public int count(char arr[],int n,char key){\n        int c=0;\n        for(int i=0;i<n;i++){\n            if(arr[i]==key){\n                c++;\n            }\n        }\n        return c;\n    }\n    public boolean digitCount(String num) {\n        char arr[]=num.toCharArray();\n        int n=arr.length;\n        for(int i=0;i<n;i++){\n            char key=(char)(i+\'0\');\n            int x=count(arr,n,key);\n            int y=(int)(arr[i]-\'0\');\n            if(y!=x){\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```
['Java']