JAVA || SOLUTION
\n\n# Code\n\nclass Solution {\n  public boolean digitCount(String num) {\n    final char[] digit = num.toCharArray(); // convert string to char array\n    fina
\n\n# Code\n```\nclass Solution {\n  public boolean digitCount(String num) {\n    final char[] digit = num.toCharArray(); // convert string to char array\n    final int n = digit.length; // length of char array\n    int[] count = new int[10]; // count arr length 10 because constraint 1<=n<=10\n    for (char c : digit) {\n      count[c - \'0\']++; // count of digits \n    }\n    for (int i = 0; i < n; i++) {\n      if (digit[i] - \'0\' != count[i]) { // check \n        return false;\n      }\n    }\n\n    return true;\n  }\n}\n\n// DRY RUN TO CLEARLY UNDERSTAND THE WORKING OF CODE \n```
['Java']