Code RoomAccount balance goes negative
HardPrep Room Coding #2276

Account balance goes negative

Code reviewConcurrencyMid–Senior~18 min

This account-debit code runs in a multi-threaded server. What's wrong?

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 18 min
Mark a line and say what kind of problem it is.0 findings
1def withdraw(account, amount):
2 if account.balance >= amount:
3 account.balance -= amount
4 return True
5 return False
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.