Optimize money redistribution across bank accounts to meet threshold requirements.
Problem: Given array of account balances and threshold, redistribute money to ensure all accounts exceed threshold.
Example: Input:
Steps:
Final: [10, 10, 11, 16]
Follow-up:
Design a backend system for StripePay that handles user transactions and balance management.
Requirements:
Supported Commands:
Usage: INIT,name,balance,bank_1,bank_2,...,bank_n
Purpose: Initialize user account with starting balance and connected banks
Example: INIT,Alice,100,BankA,BankB
Response: No response value
Usage: POST,timestamp,sender,receiver,amount
Purpose: Process money transfers between users or banks
Example: POST,169800812,Bob,Alice,50
Rules:
- Prevent negative balances
- Handle bank deposits/withdrawals
- Validate bank connections
- Verify user accounts exist
Response: SUCCESS or FAILURE
Usage: GET,timestamp,name
Purpose: Retrieve account balance at specific timestamp
Example: GET,2,Alice
Response: Balance amount or FAILURE
Constraints:
Output Format: Return comma-separated string of command responses in sequential order of input commands.