Skip to main content
hardNeetCode 150

Sliding Window Maximum

Given an array nums and a sliding window of size k Return an array of the maximum value in each window position Example: nums = [1,3,-1,-3,5,3,6,7], k = 3 => [3,3,5,5,6,7] Use a deque (double-ended queue) for O(n) time complexity

This problem is a great test of whether you can keep window state consistent as it moves. It's a hard one for a reason: it stresses stateful scanning when the rules pile up. Be disciplined about counts and boundaries; most bugs are off-by-one window moves.

Arrays & HashingStackHeap / Priority QueueSliding Window

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Find Maximum in Each Sliding Windowhard
2Part 2
3Part 3

Each locked part opens in the editor once the part before it passes.

Based onLeetCode