Easy Sliding Window Based + Hand written explaination O(N)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n\n\n\n\n\n\n# Complex
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n![Screenshot_20230108_022223.png](https://assets.leetcode.com/users/images/21e65b30-4253-4ebe-8026-8e6d72fa9575_1673124949.6130683.png)\n![Screenshot_20230108_022249.png](https://assets.leetcode.com/users/images/6a92b7fc-f553-4974-9e96-1bc2809f27a1_1673124960.6026196.png)\n![Screenshot_20230108_022319.png](https://assets.leetcode.com/users/images/df7afb61-d44d-4978-b122-d3c65f28804b_1673124971.7303674.png)\n![Screenshot_20230108_022330.png](https://assets.leetcode.com/users/images/322a9dfe-2482-4c97-ae7c-c1c32a775709_1673124983.167437.png)\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfSubstrings(string s)\n    {\n        int l=0,r=0,end=s.length()-1;\n        int n=s.length();\n        unordered_map<char,int>map;\n        int count=0;\n        while(r<n)\n        {\n            //increment the char at the right index\n            map[s[r]]++;\n            while(map[\'a\']>=1 && map[\'b\']>=1 && map[\'c\']>=1)\n            {\n                //we need to add 1 for the current subarray + all the subarray on the right of the r pointer\n                count+=1+(end-r);\n\n                map[s[l]]--;\n                l++;\n            }\n            r++;\n        }\n        return count;\n    }\n};\n```
['C++']