← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are writing software for a credit card provider. Implement a system that processes a list of operations and returns the final card-holder balances.
Operations:
["Add", card_holder, card_number, "$<limit>"] — create a new card. The card_holder is guaranteed unique. New cards start with a $0 balance. Card numbers must be validated.["Charge", card_holder, "$<amount>"] — increase the balance by amount. If the resulting balance would exceed the card's limit, the charge is declined (ignored). Charges against an invalid card are ignored.["Credit", card_holder, "$<amount>"] — decrease the balance by amount. Credits may push the balance below $0 (negative balance is allowed). Credits against an invalid card are ignored.Card-number validation (basic): the card number must consist of digits [0-9] only and have length between 12 and 16 inclusive.
Output: return the list of [card_holder, balance_string] pairs, sorted lexicographically by card_holder. The balance string is formatted "$<n>" (negative balances format as "$-<n>"). For invalid card numbers, output "error" instead of the balance — the card holder still appears in the output.
Method signature: the entry-point class is Solution with method creditCardProvider(operations) returning a list of [name, balance_or_error] pairs.