Peak Orders Across Every Rolling Window of Minutes
Last updated: November 29, 2026
Quick Overview
Given a count of online orders for each minute, return the maximum count within every contiguous window of k minutes.
Walmart Labs
November 29, 20260
0
0 solved
Given a count of online orders for each minute, return the maximum count within every contiguous window of k minutes.
Capacity dashboards for Walmart.com during events like Black Friday track rolling peaks of order volume to size checkout services. The Walmart Labs technical screen expects a monotonic deque that gives O(n) rather than a heap or a naive rescan.
What the Interviewer Expects
- Start from the O(nk) baseline and improve it
- Keep a deque of indices with decreasing values
- Drop indices that fall out of the window from the front
- Drop dominated values from the back
- Explain the amortized O(n) bound
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you compute this on an unbounded stream with a fixed memory budget?
- How would you compute the rolling minimum and maximum together?
- What if events arrive with timestamps rather than one count per minute?
- How would you compute it across 4,700 stores at once in a stream processor?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of non-negative integers, one per minute, and window size k. Output: list of n - k + 1 maxima, one per window. If k is out of range, return []....
High-Level Design
Rescanning each window costs O(nk) and a heap with lazy deletion costs O(n log n). A deque of indices does better. Invariant: values at the indices in the deque are strictly decreasing from front to b...