Skip to main content
All Questions

Divide a sum of money as evenly as possible among recipients, capped by amounts owed.

Unlock detailed company stats for this questionUpgrade

Given an amount of money to distribute between multiple recipients and a map from recipient name to the amount owed to that recipient, write a function that divides the money as evenly as possible between the recipients. All money amounts are integers, and no recipient is paid more than they are owed.

Sample inputs and outputs: input: {'ryan': 10, 'stephanie': 10, 'quentin': 10, 'upeka': 10}, total=40 -> {'ryan': 10, 'stephanie': 10, 'quentin': 10, 'upeka': 10} input: {'ryan': 10, 'stephanie': 10, 'quentin': 10, 'upeka': 10}, total=20 -> {'ryan': 5, 'stephanie': 5, 'quentin': 5, 'upeka': 5} input: {'ryan': 2, 'stephanie': 10, 'quentin': 10, 'upeka': 10}, total=21 -> {'ryan': 2, 'stephanie': 6, 'quentin': 7, 'upeka': 6} input: {'ryan': 2, 'stephanie': 10, 'quentin': 10, 'upeka': 10}, total=22 -> {'ryan': 2, 'stephanie': 7, 'quentin': 7, 'upeka': 6}

Format · Technical screen; the same problem appears across Gusto SWE screens.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.