A fixed or variable-size window is moved through a data structure, typically an array or string, to solve problems efficiently based on continuous subsets of elements
Problem Statement: Given a string, return the length of the longest substring without repeating characters. Examples Example 1: Input: string s = “cadbzabcd” Output: 5 Explanation: All possible...
Problem Statement: Given an array that represents the values of N different cards and an integer K. The task is to pick out K cards and at each step pick out one card either from the beginning or f...
Problem Statement: Given an array and an integer K, return the minimum length of subarrays with sum greater than or equal to K. Examples Example 1: Input:arr= [2, 3, 1, 2, 4, 3], K= 7 Output:2 Expl...
Problem Statement: Given an array and an integer K, return the maximum sum that can be obtained by picking up K elements consecutively. Examples Example 1: Input:arr= [-1, 2, 3, 3, 4, 5, -1], K= 4...