Minutes Until a Zone's Surge Multiplier Rises Again
Last updated: November 29, 2026
Quick Overview
Given a zone's surge multiplier sampled once per minute, return for each minute how many minutes until a strictly higher multiplier appears, or 0 if it never does.
Uber
November 29, 20260
0
0 solved
Given a zone's surge multiplier sampled once per minute, return for each minute how many minutes until a strictly higher multiplier appears, or 0 if it never does.
A monotonic stack warm-up in the style of Uber's phone screens, using surge pricing data that drivers watch closely. The interviewer wants the O(n) stack solution and a clear statement of the stack invariant.
What the Interviewer Expects
- Starts from the O(n^2) baseline and improves it
- Keeps a stack of indices with non-increasing values
- Resolves waiting indices when a higher value arrives
- Leaves unresolved indices at 0
- Explains why each index is pushed and popped once
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 instead find the previous higher multiplier?
- What if the series is circular (a repeating daily pattern)?
- How would you answer this over a live stream where future values are unknown?
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 floats or ints, length up to . Output: list of ints of the same length. Strictly higher means equal values do not count. A nested loop is and too slow at this size....
High-Level Design
Scan left to right with a stack of indices still waiting for a higher value. Invariant: their multipliers are non-increasing from bottom to top. When the current value is strictly higher than the valu...