Days Until a Strictly Lower Rate Quote Appears

Last updated: November 29, 2026

Quick Overview

Given a list of daily APR quotes for a loan product, return for each day how many days you would wait until a strictly lower quote appears, or 0 if no lower quote ever appears.

Upstart
Coding & Algorithms
Software Engineer
Upstart
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given a list of daily APR quotes for a loan product, return for each day how many days you would wait until a strictly lower quote appears, or 0 if no lower quote ever appears.

Upstart's pricing moves with funding costs and model updates, and analysts like to know how long borrowers who waited would have needed to wait for a better rate. The assessment checks the monotonic stack pattern for next-smaller-element in linear time.

What the Interviewer Expects
  • Recognize next smaller element
  • Keep a stack of unresolved indices
  • Pop while the current quote is strictly lower
  • Record distances as indices are resolved
  • Explain the amortized O(n) bound
Key Topics to Cover
monotonic stack
arrays
next smaller element
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
  • Return the lower rate itself rather than the wait.
  • What if the quotes are a circular weekly pattern?
  • How would you answer 'lower by at least 0.5 points' instead?
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

Strictly lower only, so equal quotes do not resolve each other. Output an integer list the same length as the input....

High-Level Design

Scan left to right with a stack of indices that have not yet seen a lower quote. Rates on the stack are non-decreasing from bottom to top. When a new quote is lower than the rate at the top, that top ...


Submit Your Answer
Markdown supported