Sliding Window Maximum
A hard-tier problem at 48% community acceptance, tagged with Array, Queue, Sliding Window. Reported in interviews at Gojek and 33 others.
Sliding Window Maximum is a hard-rated problem that shows up across 34 companies, including Gojek, Booking.com, Citadel, and Roku. You're given an array and a window size k; you need to return the max value in each window as it slides across the array. The naive approach (recalculate max for each window) times out. The acceptance rate sits at 48%, which means half the candidates who attempt it don't solve it cleanly under pressure. This is the kind of problem where you either know the monotonic queue trick or you're rewriting brute force and hoping for partial credit. If this hits your live assessment and you blank, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Sliding Window Maximum"
Sliding Window Maximum is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe trick is a monotonic deque. Most candidates try a max-heap or re-scan each window, both too slow for large arrays. The deque stores indices in decreasing order of their values: front always holds the max in the current window. As you slide, you remove indices that fall outside the window, discard smaller values before adding the new one, and record the front. This runs in O(n) time because each element enters and leaves the deque exactly once. Common pitfalls: confusing index removal with value removal, or forgetting to clean stale indices at the start. The pattern bridges Array, Queue, and Monotonic Queue thinking. If you haven't drilled this specific structure before hitting the assessment, StealthCoder is the hedge that surfaces a working solution on demand.
Pattern tags
You know the problem.
Make sure you actually pass it.
Sliding Window Maximum recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Sliding Window Maximum interview FAQ
Why does the naive max-per-window approach fail?+
Recalculating the max for each of n windows takes O(n*k) time. For large arrays and moderate k, this exceeds time limits on most assessments. Monotonic queue reduces it to O(n), which is why it's the expected solution.
Is this still asked at Booking.com and Citadel?+
Yes. The input data shows both companies in the top ten that ask it. Hard-rated problems with 34 company reports and sub-50% acceptance are core to technical screening at tier-1 shops. Expect it if you interview there.
What's the monotonic queue trick exactly?+
Maintain a deque of indices in decreasing order of array values. For each new element, remove indices outside the window, pop smaller values from the back, append the new index, then record the front (current max). Each element enters and exits once, so it's O(n).
Can I use a heap instead of a deque?+
A max-heap works but it's slower. You insert n elements and potentially extract many stale ones from the heap. That's O(n log n) best case. Monotonic queue is O(n) and avoids the heap overhead, so it's the preferred approach in interviews.
How does this relate to other monotonic queue problems?+
Monotonic Queue is a sub-topic here. The pattern applies to other problems like Next Greater Element and Trapping Rain Water. Mastering this structure unlocks a whole class of hard array problems across multiple companies.
Want the actual problem statement? View "Sliding Window Maximum" on LeetCode →