Maximum In Every Window
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Maximum In Every Window
A sensor records a sequence of integer readings. For every contiguous block of exactly k readings, report the largest value inside that block. Return all window maximums from left to right.
Examples
Example 1
Input:
1 3 -1 -3 5 3 6 7 3
Output:
3 3 5 5 6 7
Approach hint
Keep only useful candidates for the maximum of the current window.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp