Find the Smallest Daily Payment Limit That Meets Every Bill Due Date

Last updated: November 29, 2026

Quick Overview

Bills must be paid in a fixed order. Each day you send whole bills in order as long as that day's total stays within a daily limit. Given each bill's amount and due day, find the smallest limit that pays every bill on or before its due day.

Ramp
Coding & Algorithms
Software Engineer
Ramp
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Medium

0

0

0 solved


Bills must be paid in a fixed order. Each day you send whole bills in order as long as that day's total stays within a daily limit. Given each bill's amount and due day, find the smallest limit that pays every bill on or before its due day.

Ramp bill pay schedules payments against a company's cash position and bank transfer limits, so knowing the lowest daily outflow that still avoids late fees is a real question. The interviewer checks that you see a monotone feasibility check and binary search on the answer, and can justify the greedy check.

What the Interviewer Expects
  • Notices feasibility is monotone in the limit, enabling binary search on the answer
  • Sets correct bounds: the largest single bill and the total
  • Writes a greedy check that packs each day as full as possible
  • Explains why greedy packing gives every bill its earliest possible payment day
  • Verifies against a brute force on small inputs
Key Topics to Cover
Binary search on answer
Greedy
Monotonicity
Simulation
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
  • What if bills may be split across days?
  • What if the order is not fixed and you may reorder by due date?
  • How would you add a cap on how many bills can be sent per day?
  • Can you solve it without binary search?
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: bills as (amount, due_day) in payment order, days starting at 1. A bill cannot be split. Output the minimum integer daily limit under which every bill is paid by its due day....

High-Level Design

If a limit L works, any larger limit also works, since every day can carry at least as much. That monotonicity lets me binary search L between max(amount) (a smaller limit cannot pay the biggest bil...


Submit Your Answer
Markdown supported

Related Questions