Microsoft | SSE

Anonymous User
1010
Aug 07, 2023

We are a payment API operator, we keep track of where the money is and move money between bank accounts to make sure their balances are not below
some threshold. This is for operational and regulatory reasons, eg we should have enough funds to pay out to our users, and we are legally
required to separate our users' funds from our own. This interview question is a simplified version of a real-world problem we have here.

Let's say there are at most 500 bank accounts, some of their balances are above 100 and some are below. How do you move money between them so that they all have at least 100?

Example input:
-AU: 80
-US: 140
-MX: 110
-SG: 120
-FR: 70

Output:
-from: US, to: AU, amount: 20
-from: US, to: FR, amount: 20
-from: MX, to: FR, amount: 10

Comments (6)