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
Coding & Algorithms
Data Engineer
Walmart Labs
November 29, 2026
Data Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
monotonic queue
sliding window
deque
streaming
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported