Problem Β· Hash Table

Account Balance Manager Part 3 - Platform Coverage

Learn this problem
● MediumStripe logoStripeFULLTIMEONSITE INTERVIEW
See Stripe hiring insights

Problem statement

Practice sequence

  1. Part 1: Calculate Totals
  2. Part 2: Reject Overdrafts
  3. Part 3: Platform Coverage (you are here)

What the interview report shared

The coding round centered on Account Balance / Bank Transaction and contained three questions.

Practice contract

For this exercise, assume transactions arrive in order as account_id,amount strings, every account starts with a balance of 0, and one identifier names the platform account.

  • Apply a transaction normally when the resulting balance is non-negative.
  • When a non-platform account would become negative, the platform covers exactly the shortfall so that account ends at 0.
  • The platform account's own transactions are never covered, and sufficient platform funding is available.

Return the total amount covered by the platform.

Function

processWithCoverage(transactions: String[], platformAccount: String) β†’ int

Examples

Example 1

transactions = ["platform,1000", "account_A,100", "account_A,-150", "account_B,50", "account_B,-100", "account_A,-30"]platformAccount = "platform"return = 130
platform +1000 -> 1000. account_A +100 -> 100. account_A -150 -> would be -50, platform pays 50, account_A becomes 0 (covered total 50). account_B +50 -> 50. account_B -100 -> would be -50, platform pays 50, account_B becomes 0 (covered total 100). account_A -30 -> would be -30, platform pays 30, account_A becomes 0 (covered total 130). Total covered = 130.

Example 2

transactions = ["platform,500", "account_A,20", "account_A,-20"]platformAccount = "platform"return = 0
account_A +20 -> 20, then -20 -> exactly 0, which does not go negative, so no coverage is needed. The platform pays nothing.

Constraints

  • 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.

More Stripe problems

drafts saved locally
public int processWithCoverage(String[] transactions, String platformAccount) {
  // write your code here
}
transactions["platform,1000", "account_A,100", "account_A,-150", "account_B,50", "account_B,-100", "account_A,-30"]
platformAccount"platform"
expected130
checking account