FastPrepFair Capped Money Distribution
Problems/Fair Capped Money Distribution

Fair Capped Money Distribution

Gusto logoGusto● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report asks to hand out money as evenly as possible, without paying anyone more than they are owed, and includes one complete example. It does not say how to handle units that cannot be split or how to break ties on leftovers. Our version is about 88% the same as the reported question.

You have amount units of money to hand out. A unit is the smallest piece of the currency, such as one cent, and amount is a whole number that is zero or more. You also get an array owed in a fixed order, where owed[i] is the most recipient i may receive. We call this limit the recipient's cap.

Hand out the money in rounds. In each round, go through the recipients in order and give one unit to each recipient who still has less than they are owed. Stop when the money runs out or every recipient is paid in full. Return how much each recipient got, in the original order.

This way, payments are as even as the caps allow. Units left over after the last full round go to the earlier recipients first. No one gets more than they are owed, and exactly min(amount, sum(owed)) units are handed out in total.

Function

distributeMoney(amount: long, owed: long[]) → long[]

Examples

Example 1

amount = 40owed = [10,10,10,10]return = [10,10,10,10]

The available amount exactly covers every recipient's cap.

Example 2

amount = 10owed = [2,100,100]return = [2,4,4]

The first recipient reaches its cap at 2. The remaining units are split evenly between the other two recipients.

Example 3

amount = 5owed = [10,10,10]return = [2,2,1]

One complete round gives everyone one unit. The two leftover units go to the first two recipients.

Constraints

  • 0 <= amount <= 10^18.
  • 1 <= owed.length <= 100000.
  • 0 <= owed[i] <= 10^18.
  • The sum of all owed amounts fits a signed 64-bit integer.

More Gusto Onsite Interview questions

  • Response Time Stats by URL PatternONSITE INTERVIEW · Seen Nov 2026
  • Tax Calculation with Year and Filing RulesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • Remove the Fewest Magic BeansThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Aggressive CowsAmazon · PHONE SCREEN
  • Unit-Weight Knapsack with Limited QuantitiesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimize Range After Three ChangesDRW · PHONE SCREENDRW interview questions
  • Reduce Array Size to At Most HalfMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Maximize Monsters DefeatedSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
All Gusto interview questionsSee Gusto hiring insights
Saved
class Solution {
    public long[] distributeMoney(long amount, long[] owed) {
      // Write your code here.
    }
}
Checking account…