Peak Surge Multiplier in Every Rolling Pricing Window
Last updated: November 29, 2026
Quick Overview
Given per-minute surge multipliers for a zone and a window size k, return the maximum multiplier in every contiguous window of k minutes, in order.
Uber
November 29, 20260
0
0 solved
Given per-minute surge multipliers for a zone and a window size k, return the maximum multiplier in every contiguous window of k minutes, in order.
Uber's pricing and driver-incentive dashboards show rolling peaks, which makes this monotonic deque problem a natural technical screen. The interviewer wants O(n) using a deque of indices and an explanation of why stale and dominated entries can be dropped.
What the Interviewer Expects
- Explains why a heap gives O(n log k) but a deque gives O(n)
- Keeps deque values decreasing from front to back
- Evicts the front when it leaves the window
- Starts emitting once the first full window is seen
- Handles k larger than the series
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 return the rolling minimum at the same time?
- What if samples arrive irregularly and the window is 10 minutes of wall-clock time?
- How would you compute this per zone for thousands of zones 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 numbers and k >= 1. Output: list of n - k + 1 maxima, or empty if k > n. Brute force is , which is too slow for a day of data across many zones....
High-Level Design
Maintain a deque of indices whose values are strictly decreasing from front to back. When a new value arrives, pop from the back every index whose value is less than or equal to it: those can never be...