Intuition from brute force to O(N) for all kinds of arrays
Brute Force\nTime = O(N^2)\nSpace = O(26) for chars, O(N) for ints.\n\n##### Two Pointer 1\n\n1. Iterate over string while storing counts.\n2. While count of ch
##### Brute Force\nTime = O(N^2)\nSpace = O(26) for chars, O(N) for ints.\n\n##### Two Pointer 1\n\n1. Iterate over string while storing counts.\n2. While count of char == k, iterate while removing elements from left.\n3. For each such iteration, ans += n - r, since if for an index r the count is >=k, the condition will be true for all i > r.\n4. Return ans. \n\nTime: O(N)\nSpace = O(26) for chars, O(N) for ints.\n\n\n##### Two Pointer 2 (most optimal)\n\n1. Count total subarrays possible = n*(n+1)//2\n2. Instead of counting for freq >=k, count subarrays with freq of all characters < k.\n3. Remove these subarrays fro total possible subarrays.\n4. This will give subarrays where frequencey of atleast a single character is >= k.\n\nTime: O(N)\nSpace = O(26) for chars, O(N) for ints.\n
['Array', 'Two Pointers', 'Python3']