Posts

Showing posts with the label Sliding Window

Sliding Window

Image
Imagine that you're allowed to select 3 chocolate chip cookies in a contiguous subarray. Your goal is to find a window of 3 cookies with the most amount of chips! The same concept can be applied to arrays or strings. The window boundry is defined by the left and right pointers as shown in the picture below: Sliding window, k = 3 Example: Find the Maximum of subarray Detect repeating pattren in a string