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
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
Monotonic deque
Sliding window
Arrays
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 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 Problems
Sample Answer
Requirements

Input: list of numbers and k >= 1. Output: list of n - k + 1 maxima, or empty if k > n. Brute force is O(nk)O(nk), 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...


Submit Your Answer
Markdown supported