Advancedcoding Verified
Given an array and a window size k, return the maximum of every contiguous window of size k (Sliding Window Maximum).
ReportedSource: GeeksforGeeks interview experience: Amazon SDE-1 off-campus
Quick answerFree
Monotonic deque of indices with decreasing values: drop indices that left the window from the front, pop smaller values from the back, the front is the max. O(n) time, O(k) space.
Detailed answer· 89 words
Interview PrepUnlock the full answer with Interview Prep
Get a 89-word model answer and a runnable reference solution, plus 61 more DSA questions.
Also in Pro (₹499 / 90 days).
Reference solution· runs in the browser sandbox
Interview PrepUnlock with Interview Prep
+ 61 more DSA questions in Interview Prep, each with the full answer.