
Pruning unnecessary recursion branches...

Pruning unnecessary recursion branches...
Maintain a window of elements to solve subarray/substring problems
Given an array of integers and a positive integer k, find the maximum sum of any contiguous subarray of size exactly k.
Given an array of positive integers and a target sum S, find the length of the smallest contiguous subarray whose sum is greater than or equal to S.
Given a string and an integer k, find the length of the longest substring that contains at most k distinct characters.
Design a class that calculates the moving average of the last k values in a stream of integers.
Master the fundamental pattern. Each problem teaches you when and how to apply this technique.