Fixed window problem:

In a fixed window problem, we have a predefined window size that remains constant throughout the problem-solving process. The template for solving a fixed window problem involves maintaining two pointers, low and high, that represent the indices of the current window. The process involves iterating over the array or sequence, adjusting the window as necessary, and performing computations or operations on the elements within the window.

Variable window:

The template for solving a variable window problem involves maintaining two pointers, start and end, which represent the indices of the current window.

  1. Expand the window: Check a condition to determine whether to expand the window. If the condition is satisfied, increment the end pointer to expand the window size.
  2. Process the window: Once the window size meets the desired criteria or condition, perform the required computations or operations on the elements within the window.
  3. Adjust the window size: If the window size exceeds the desired criteria, adjust the window by moving the start pointer. Iterate or loop until the window size matches the desired criteria, and update the window accordingly.

link

121. Best time to buy and sell stock https://leetcode.com/problems/best-time-to-buy-and-sell-stock/

3. Longest Substring without repeating characters https://leetcode.com/problems/longest-substring-without-repeating-characters/description/

567. Permutation in String https://leetcode.com/problems/permutation-in-string/