← All questions
Coding
Sum of Maximums of Every Window of Size K
Asked at
Walmart
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Validate k is between one and array length.
- 02Keep indices in a deque with values decreasing from front to back.
- 03Remove expired front indices and dominated back indices for each new element.
- 04After a full window, add the front value to the running answer.
Reference answer
Then expect these follow-ups
Why is the deque monotonic?
Tests: invariant
How do duplicates affect the back-pop comparison?
Tests: edge cases
Hiring now
Get the Walmart interview, not just the prep
landed applies to roles like these for you, on each company’s own site, with answers written for the role.
Get 5x interviews10 free auto-applies. No card.
Next question