O(N) solution
\nclass Solution {\n    public boolean digitCount(String num) {\n          HashMap<Integer,Integer> map = new HashMap<>();\n//        First we are marking the f
```\nclass Solution {\n    public boolean digitCount(String num) {\n          HashMap<Integer,Integer> map = new HashMap<>();\n//        First we are marking the frequency for the number. As we are given in the question, num.charAt(i) is the\n//        frequency of the number i in the num String.\n        for(int number = 0; number < num.length(); number++){\n            int frequency = Character.getNumericValue(num.charAt(number));\n            map.put(number,frequency);\n        }\n//        Now we are traversing through the string.\n        for(int index = 0; index< num.length(); index++) {\n//            If character at index i is less than num.length(), then only we need to know its frequency.\n            if (Character.getNumericValue(num.charAt(index)) < num.length()) {\n//                Get the frequency of the number and subtract 1 from it if it is present.\n                int frequency = map.get(Character.getNumericValue(num.charAt(index))) - 1;\n                map.put(Character.getNumericValue(num.charAt(index)), frequency);\n            }\n        }\n//      If all the values are 0 , then only it is right otherwise , the frequency is either more or less than the\n//        specified frequency, hence return false;\n        for (int i = 0; i < num.length(); i++) {\n            if(map.get(i) !=0){\n                return false;\n            }\n        }\n\n        return true;\n    }\n}\n```\nIf you liked the solution or found the solution unique , please upvote :)\nThank you
['Java']