Gusto | Software Engineer | USA
Anonymous User
539
Mar 27, 2025
Given an amount and receipts (name, desired_amount), distribute the amount across the recipients using the following criteria:
- The amount should be divided across recipients equally
- If it cannot be done equally, top receipents with the name sorted alphabetically should get their amount first.
Examples:
- Receipents: {a: 10, b: 10, c:10, d:10}, Amount: 40
- Answer: {a: 10, b: 10, c:10, d:10} will get the desired amount as it can be divided equally
- Receipents: {a: 10, b: 10, c:10, d:10}, Amount: 33
- Answer: {a: 9, b: 8, c:8, d:8} will be the answer as everyone will get 8 and 'a' will get 9 becasue it is alphabetically sorted
- Receipents: {a: 10, b: 10, c:10, d:10}, Amount: 33
- Answer: {a: 9, b: 9, c:8, d:8} will be the answer as everyone will get 8 and 'a' and 'b' will get 9 becasue it is alphabetically sorted.
I assumed that the output of the last question will be {a: 10, b: 8, c:8, d:8} due to greedy approach but that was wrong.
Decision: Reject mostly due to invalid assumption.
Comments (2)


