Aditya Verma | Sliding Window Pattern | C++
\n\n\n\n\n## Aditya Verma - Variable Sized Sliding Window Approach\n\n## Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n\n- 
\n\n\n\n\n## Aditya Verma - Variable Sized Sliding Window Approach\n\n## Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n## Code\n```cpp []\nclass Solution {\npublic:\n    int numberOfSubstrings(string s, int k) {\n        unordered_map<char,int> mp;\n        int i=0,j=0;\n        int ans=0;\n        while(j < s.size()){\n            mp[s[j]]++;\n            if(mp[s[j]] < k) j++;\n            else if(mp[s[j]] >= k){\n                while(mp[s[j]] >= k){\n                    // Remove calculations for i\n                    mp[s[i]]--;\n                    if(mp[s[i]] == 0) mp.erase(s[i]);\n                    i++;\n                    // Calculate ans\n                    ans += s.size() - j;\n                }\n                j++;\n            }\n        }\n        return ans;\n    }\n};\n```
['Sliding Window', 'C++']