This continues the account balance manager. You are given a list of transactions in order (each "account_id,amount") and the id of a special platform_account.
Now, instead of rejecting a withdrawal that would make a user's balance negative, the platform covers the shortfall: transfer exactly enough money from the platform account so the user's balance ends at exactly 0. The transaction still happens (the user balance becomes 0), the platform account is debited by the shortfall, and you accumulate the covered amount.
The platform account itself behaves like a normal account for its own transactions — only regular users are covered, never the platform. Assume the platform account always has enough money.
Return the total amount the platform account had to pay across all transactions, as an integer.
transactions = ["platform,1000", "account_A,100", "account_A,-150", "account_B,50", "account_B,-100", "account_A,-30"] platformAccount = "platform" return = 130
transactions = ["platform,500", "account_A,20", "account_A,-20"] platformAccount = "platform" return = 0
- Each transaction is
"account_id,amount"with an integer amount. - When a non-platform account would go negative, the platform covers the shortfall so that account ends at exactly 0, and the platform account is debited by that shortfall.
- The platform account is treated as a normal account for its own transactions and is never itself covered.
- Assume the platform always has enough money.
- Return the total amount paid by the platform as an integer.
- BitFont Part 3 - Decode Run-Length-Encoded RowsONSITE INTERVIEW · Seen Jun 2026
- Record Linkage Part 3 - Full Connected ComponentPHONE SCREEN · Seen Jun 2026
- Shipping Cost Calculator Part 3 - Mixed Fixed/Incremental TiersONSITE INTERVIEW · Seen Jun 2026
- Transaction Fee Calculator - Per-Merchant Volume DiscountPHONE SCREEN · Seen Jun 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 2 - Render a WordONSITE INTERVIEW · Seen Jun 2026
- Factory Cost - Min-Cost Path Skipping One StagePHONE SCREEN · Seen Jun 2026
- HTTP Accept-Language with Quality Scores (q-factors)ONSITE INTERVIEW · Seen Jun 2026
public int processWithCoverage(String[] transactions, String platformAccount) {
// write your code here
}