Make a Racy BankAccount Deposit Thread-Safe Without Editing the Class, in Python and Go
Company: xAI
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
Overview: A concurrency question built around a BankAccount class whose deposit method reads the balance, sleeps, then writes it back. Candidates find every race, make deposits thread-safe through a subclass or wrapper without editing or copying the class, and carry the fix over to Go, which has no inheritance.