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

0

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
Monotonic stack
Next greater element
Arrays
Amortized analysis
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 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 Problems
Sample Answer
Requirements

Input: list of floats or ints, length up to 10510^5. Output: list of ints of the same length. Strictly higher means equal values do not count. A nested loop is O(n2)O(n^2) 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...


Submit Your Answer
Markdown supported

Related Questions