Approve Wholesale Orders Against a Rolling Net 60 Credit Limit

Last updated: November 29, 2026

Quick Overview

A retailer has a fixed credit limit and each approved order is repaid exactly 60 days after it is placed. Given orders in time order as (day, order_id, amount), decide which orders are approved if an order is approved only when outstanding balance plus its amount stays within the limit.

Faire
Coding & Algorithms
Software Engineer
Faire
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A retailer has a fixed credit limit and each approved order is repaid exactly 60 days after it is placed. Given orders in time order as (day, order_id, amount), decide which orders are approved if an order is approved only when outstanding balance plus its amount stays within the limit.

Net 60 terms are a core part of the retailer offer, so the marketplace carries each retailer's receivable until it is paid. The interviewer wants to see an event-driven simulation with a min-heap of repayments, careful boundary handling on the repayment day, and a clear statement of assumptions.

What the Interviewer Expects
  • Model outstanding balance as approved amounts not yet repaid
  • Release repayments that are due on or before the current order's day before checking the limit
  • Use a min-heap keyed by repayment day
  • Reject without changing state when the limit would be exceeded
  • State O(n log n) complexity
  • Ask whether rejected orders should be partially approved or queued
Key Topics to Cover
min-heap
event simulation
credit exposure
boundary conditions
greedy processing
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 early repayments or partial payments change the data structure?
  • What if the limit itself changes over time because of a risk model update?
  • How would you return the earliest day a rejected order could be approved?
  • How do you make this correct when two orders for the same retailer arrive concurrently?
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

Inputs: limit (cents), orders as (day, order_id, amount), and a term of 60 days. An approved order consumes credit from its day until day + 60, when it frees up. Assume repayment on day d is proce...

High-Level Design

Walk orders by day. Keep used, the outstanding exposure, and a min-heap of (repay_day, amount) for approved orders. Before each decision, pop every repayment whose day is at most the current day. Th...


Submit Your Answer
Markdown supported

Related Questions