SIMPLE SOLUTION USING ATMOST CONCEPT||TC:O(N)||SC:O(N)
Similar to leetcode 992 https://leetcode.com/problems/subarrays-with-k-different-integers/\n\n\nApproach\nwe have to find no of string with all three character\
**Similar to leetcode 992 https://leetcode.com/problems/subarrays-with-k-different-integers/\n**\n\n**Approach\nwe have to find no of string with all three character\nIt can be find using difference of no of substring with at most 3 character and atmost 2 character.**\n\nTC:O(N)\nSC:O(N)\n\n```\n\n\n\nclass Solution {\n    public int numofsubstring(String s,int k){\n        HashMap<Character,Integer>mp=new HashMap<>();\n        int distinct=0;\n        int answer=0;\n        int release=0;\n        for(int acquire=0;acquire<s.length();acquire++){\n            char ch=s.charAt(acquire);\n            if(mp.containsKey(ch)){\n                mp.put(ch,mp.get(ch)+1);\n            }else{\n                mp.put(ch,1);\n                distinct++;\n            }\n            \n            while(release<=acquire && distinct>k){\n                char chr=s.charAt(release);\n                mp.put(chr,mp.get(chr)-1);\n                if(mp.get(chr)==0){\n                    mp.remove(chr);\n                    distinct--;\n                }\n                release++;\n            }\n            answer+=acquire-release+1;\n        }\n        return answer;\n    }\n    public int numberOfSubstrings(String s) {\n        return numofsubstring(s,3)-numofsubstring(s,2);\n    }\n}\n\n```
['Hash Table', 'Math', 'String', 'Sliding Window', 'Counting']