java easy solution
\nTHIS QUESTION IS VERY SIMPLE IF U HAVE A SIMPLE LOGIC USINGOF  TWO POINTERS IN FORM OF SLIDING WINDOW \nHOW WILL ONE PERSON THINK FOR THE APPROACH \nSEE WHEN 
```\nTHIS QUESTION IS VERY SIMPLE IF U HAVE A SIMPLE LOGIC USINGOF  TWO POINTERS IN FORM OF SLIDING WINDOW \nHOW WILL ONE PERSON THINK FOR THE APPROACH \nSEE WHEN U GET THREE CHARACTERS i.e a,b,c THEN INCREMENT THE POINTER START TILL YOU LOSS THE THE THREE CHARACTER \nLET ME GIVE YOU AN EXAMPLE\n```\nabcabc\nput pointer **start** at index 0 and pointer **end** at index 0.\nthen start putting the value inside b[] array which holds the frequency\nb[a]++;\nthen move pointer end++ \n```\na```**b**cabc--->`a`b**c**abc (on this step you get abc all no)\nhere a has start pointer and b has end then put b[b]++ and then check if you are missing a character from a b c in b[] if not return true else return false what i have done in ischeck function then once you get all character present just keep on incrementing start till you get no abc in the substring \n\n\nnow when you are getting abc then put **(n-1-i) **(where i the index till where you are getting abc) put this in an back arrayList***\nwhy i am doing that  because you can form an substring using n-1-i elements for example\nsuppose abcabc if you take **abc**\nthen you can form 1.`abc`a\n                               2.`abc`ab\n                               3.`abc`abc\n and n-1-i is giving the same value that is (6-1-2)=3 put this in back arrayList\n\n\nwhile incrementing your start after getting abc substring just put count++ and when you miss abc put count in front array \nwhy i am doing this \nlet suppose it is aaabc\nyou got your i(**end pointer**) 4 and**start pointer** at 0 you will shifting the window till you get loss **abc**  and that point will be at index 3 and start pointer will be 3 at that point how much you have moved start pointer 3 times save this in front arraylist than \ndoing this because\naaabc\n1.aaabc\n2.aabc\n3.abc\nthen do one thing in sum add front(i)*back(i)+front(i) why \naaabcc\nyou got back 1 and front 3  \nyou get \n1.aaabcc\n2.aabcc\n3.abcc\n4.aaabc\n5.aabc\n6.abc\nyou got why\n\n\n\n```\n```\nTHIS QUESTION IS VERY SIMPLE IF U HAVE A SIMPLE LOGIC USINGOF  TWO POINTERS IN FORM OF SLIDING WINDOW \nHOW WILL ONE PERSON THINK FOR THE APPROACH \nSEE WHEN U GET THREE CHARACTERS i.e a,b,c THEN INCREMENT THE POINTER START TILL YOU LOSS THE THE THREE CHARACTER \nLET ME GIVE YOU AN EXAMPLE\n```\nabcabc\nput pointer **start** at index 0 and pointer **end** at index 0.\nthen start putting the value inside b[] array which holds the frequency\nb[a]++;\nthen move pointer end++ \n```\na```**b**cabc--->`a`b**c**abc (on this step you get abc all no)\nhere a has start pointer and b has end then put b[b]++ and then check if you are missing a character from a b c in b[] if not return true else return false what i have done in ischeck function then once you get all character present just keep on incrementing start till you get no abc in the substring \n\n\nnow when you are getting abc then put **(n-1-i) **(where i the index till where you are getting abc) put this in an back arrayList***\nwhy i am doing that  because you can form an substring using n-1-i elements for example\nsuppose abcabc if you take **abc**\nthen you can form 1.`abc`a\n                               2.`abc`ab\n                               3.`abc`abc\n and n-1-i is giving the same value that is (6-1-2)=3 put this in back arrayList\n\n\nwhile incrementing your start after getting abc substring just put count++ and when you miss abc put count in front array \nwhy i am doing this \nlet suppose it is aaabc\nyou got your i(**end pointer**) 4 and**start pointer** at 0 you will shifting the window till you get loss **abc**  and that point will be at index 3 and start pointer will be 3 at that point how much you have moved start pointer 3 times save this in front arraylist than \ndoing this because\naaabc\n1.aaabc\n2.aabc\n3.abc\nthen do one thing in sum add front(i)*back(i)+front(i) why \naaabcc\nyou got back 1 and front 3  \nyou get \n1.aaabcc\n2.aabcc\n3.abcc\n4.aaabc\n5.aabc\n6.abc\nyou got why\n\n\n``````\nTHIS QUESTION IS VERY SIMPLE IF U HAVE A SIMPLE LOGIC USINGOF  TWO POINTERS IN FORM OF SLIDING WINDOW \nHOW WILL ONE PERSON THINK FOR THE APPROACH \nSEE WHEN U GET THREE CHARACTERS i.e a,b,c THEN INCREMENT THE POINTER START TILL YOU LOSS THE THE THREE CHARACTER \nLET ME GIVE YOU AN EXAMPLE\n```\nabcabc\nput pointer **start** at index 0 and pointer **end** at index 0.\nthen start putting the value inside b[] array which holds the frequency\nb[a]++;\nthen move pointer end++ \n```\na```**b**cabc--->`a`b**c**abc (on this step you get abc all no)\nhere a has start pointer and b has end then put b[b]++ and then check if you are missing a character from a b c in b[] if not return true else return false what i have done in ischeck function then once you get all character present just keep on incrementing start till you get no abc in the substring \n\n\nnow when you are getting abc then put **(n-1-i) **(where i the index till where you are getting abc) put this in an back arrayList***\nwhy i am doing that  because you can form an substring using n-1-i elements for example\nsuppose abcabc if you take **abc**\nthen you can form 1.`abc`a\n                               2.`abc`ab\n                               3.`abc`abc\n and n-1-i is giving the same value that is (6-1-2)=3 put this in back arrayList\n\n\nwhile incrementing your start after getting abc substring just put count++ and when you miss abc put count in front array \nwhy i am doing this \nlet suppose it is aaabc\nyou got your i(**end pointer**) 4 and**start pointer** at 0 you will shifting the window till you get loss **abc**  and that point will be at index 3 and start pointer will be 3 at that point how much you have moved start pointer 3 times save this in front arraylist than \ndoing this because\naaabc\n1.aaabc\n2.aabc\n3.abc\nthen do one thing in sum add front(i)*back(i)+front(i) why \naaabcc\nyou got back 1 and front 3  \nyou get \n1.aaabcc\n2.aabcc\n3.abcc\n4.aaabc\n5.aabc\n6.abc\nyou got why\n\n\n\n```\nclass Solution\n{\n    public static boolean ischeck(int b[])\n    {\n        for(int i=0;i<3;i++)\n        {\n            if(b[i]==0)\n            {\n                return false;\n            }\n        }\n        return true;\n    }\n     public static boolean ischeck1(int b[])\n    {\n        for(int i=0;i<3;i++)\n        {\n            if(b[i]==0)\n            {\n                return true;\n            }\n        }\n        return false;\n    }\n    public int numberOfSubstrings(String s)\n    {\n        ArrayList<Integer> back=new ArrayList<Integer>();\n        ArrayList<Integer> front=new ArrayList<Integer>();\n        int b[]=new int[3];\n        int c=0;\n        int start=0;int end=0;int n=s.length();\n        char ch[]=s.toCharArray();\n         for(int i=0;i<n;i++)\n         {\n             b[(int)(ch[i]-\'a\')]++;\n             if(ischeck(b)==true)\n             {\n                   back.add(n-1-i);int count=0;\n                   while(ischeck1(b)==false)\n                   {\n                       count++;\n                       b[(int)(ch[start++]-\'a\')]--;\n                   }\n                 front.add(count);\n             }\n         }\n        System.out.println(front+" "+back);\n        \n       int sum=0;\n        for(int i=0;i<front.size();i++)\n        {\n            sum=sum+(front.get(i)*back.get(i))+front.get(i);\n        }\n        return sum;\n    }\n}\n```\nif u like the solution pls upvote\n\n```\n\nif u like the solution pls upvote
['Sliding Window', 'Java']