InterviewDB Experience

Credit Card Operations Software: Implement Charge, Credit, and Balance Tracking for Multiple Accounts

Interview Experience

Problem

Build a simplified credit card processing system. Implement the following operations:

  • add_card(name, limit) -- create a card with given credit limit.
  • charge(name, amount) -- charge the card; silently ignore if it would exceed the limit.
  • credit(name, amount) -- apply a payment (can go above zero, i.e., a credit balance).
  • summary() -> list[str] --

return each card's name and current balance, sorted by name.

python
class CreditCardSystem:
    def add_card(self, name: str, limit: int) -> None: ...
    def charge(self, name: str, amount: int) -> None: ...
    def credit(self, name: str, amount: int) -> None: ...
    def summary(self) -> list[str]: ...

Example:

sys.add_card("Tom", 1000)
sys.charge("Tom", 500)
sys.charge("Tom", 800)   # ignored -- would exceed limit
sys.credit("Tom", 200)
sys.summary() -> ["Tom: $300"]

Follow-ups
1. Operations on an unknown card name -- how should the system handle them?
2. Add an interest calculation method: apply_interest(rate) adds balance * rate to each positive balance.
3. How would you persist this system to disk so it survives restarts?
4. Concurrency: two threads charge the same card simultaneously. How do you prevent a race condition?

Full Details

Problem

Build a simplified credit card processing system. Implement the following operations:

  • add_card(name, limit) -- create a card with given credit limit.
  • charge(name, amount) -- charge the card; silently ignore if it would exceed the limit.
  • credit(name, amount) -- apply a payment (can go above zero, i.e., a credit balance).
  • summary() -> list[str] --

return each card's name and current balance, sorted by name.

python
class CreditCardSystem:
    def add_card(self, name: str, limit: int) -> None: ...
    def charge(self, name: str, amount: int) -> None: ...
    def credit(self, name: str, amount: int) -> None: ...
    def summary(self) -> list[str]: ...

Example:

sys.add_card("Tom", 1000)
sys.charge("Tom", 500)
sys.charge("Tom", 800)   # ignored -- would exceed limit
sys.credit("Tom", 200)
sys.summary() -> ["Tom: $300"]

Follow-ups
1. Operations on an unknown card name -- how should the system handle them?
2. Add an interest calculation method: apply_interest(rate) adds balance * rate to each positive balance.
3. How would you persist this system to disk so it survives restarts?
4. Concurrency: two threads charge the same card simultaneously. How do you prevent a race condition?

About This Question

This is a candidate experience report from a chime interview during the phone round.

It covers the following topics: Coding, Phone .