No HashMap || Faster than 98% || Arrays || Java
Runtime :7ms faster than 98% submission.\nObservation before coding : Starting from an index ,if you will increase window size till all three are included in yo
**Runtime :7ms faster than 98% submission.**\nObservation before coding : Starting from an index ,if you will increase window size till all three are included in your window,its obvious that if you add all the remaining characters after that it will also have the occurence of these three characters . So we need to expand our right pointer to the point where we have atleast 1 occurence of each and then for the current starting point total subsets possible will be (**arr.length - i)** . Once we add this to counter we will keep on decreasing left pointer till we looses the occurence of any three and again after that increase right pointer and so on.\nI am not sure if this implementation is avaialable ,but if you think this to be a good and understandable,please **UpVote** .\nclass Solution {\n    public int numberOfSubstrings(String s) {\n        char []ch= s.toCharArray();\n        int len=ch.length;\n        int left=0;\n        int count=0;\n        int []alpha= new int[3];\n        int required=0;\n        for(int i=0;i<len;i++){\n            char curr= ch[i];\n            alpha[curr-\'a\']++;\n            while(alpha[0]>0 && alpha[1]>0 && alpha[2]>0){\n                count+=len-i;\n                char le=ch[left];\n                alpha[le-\'a\']--;\n                left++;\n            }\n            \n        }\n        return count;\n        \n    }\n}
['Array', 'Sliding Window', 'Java']