22. Sliding Window & 2 pointer
4 PATTERNS IN SLIDING WINDOW QUESTION- constant window longest subarray no of subarrays shotest window (imp)--when u r not sure of shrinking/ expanding ----------------------------------------------------------------------------------------------------------- 1.) Constant Window- e.g., subarray with max sum and length 'k' ------------------------------------------------------------------------------------------------------------------------- 2.) Longest subarray or substring problem with a condition- go from brute-->better-->optimal e.g., longest subarray with sum<k -------- BETTER- [ time- O(2N) ] 1. start with window of size 1 2. expand and shrink window size 3. when condition violated shrink till condition again becomes true ------------- OPTIMAL- ( time-O(N) ) shrinking ko khatam krke O(n) me krenge... shrinking bahut barr krne se acha ek baar krdo bas BUT, if asked to print all subarrays then nothing can be done to reduce 2n ------------------------------------...