FastPrepCredit Card Command Processor
Problems/Credit Card Command Processor

Credit Card Command Processor

Chime logoChime● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The complete commands, validation rules, and example are visible in the source attachment. The judged task matches it at about 99%.

Process a batch of credit-card commands. Each cardholder is added at most once and starts with balance $0.

CommandBehavior
["Add", name, cardNumber, "$limit"]Create the account. A card is valid only when it has 12 to 16 digits and passes the Luhn check.
["Charge", name, "$amount"]Increase a valid card's balance unless the new balance would exceed its limit. Ignore the command for an invalid card.
["Credit", name, "$amount"]Decrease a valid card's balance. Negative balances are allowed. Ignore the command for an invalid card.

Return one row per cardholder, sorted by name. A valid card returns [name, "$balance"]; an invalid card returns [name, "error"]. Names are compared by character code, so uppercase letters sort before lowercase letters.

Function

processCardCommands(operations: String[][]) → String[][]

Examples

Example 1

operations = [["Add","Tom","4111111111111111","$1000"],["Add","Lisa","5454545454545454","$3000"],["Add","Quincy","12345678901234","$2000"],["Charge","Tom","$500"],["Charge","Tom","$800"],["Charge","Lisa","$7"],["Credit","Lisa","$100"],["Credit","Quincy","$200"]]return = [["Lisa","$-93"],["Quincy","error"],["Tom","$500"]]

Tom's second charge is declined because it would exceed his limit. Lisa's credit makes her balance negative, and Quincy's invalid card reports an error.

Example 2

operations = [["Add","Amy","4012888888881881","$100"],["Add","Zed","123456789012","$50"],["Charge","Amy","$100"],["Charge","Amy","$1"],["Credit","Amy","$25"],["Credit","Zed","$10"]]return = [["Amy","$75"],["Zed","error"]]

Amy reaches her limit, the next charge is ignored, and a later credit lowers the balance. Zed's invalid card ignores its credit.

Constraints

  • 1 <= operations.length <= 100000.
  • Every operation has one of the documented shapes, and every referenced name was added earlier.
  • Names contain between 1 and 50 ASCII letters and are unique.
  • Limits and amounts are decimal integers between 0 and 10^9 prefixed by $.
  • Every valid account balance fits in a signed 64-bit integer.
  • Card numbers contain between 1 and 20 decimal digits and nothing else.

Similar questions at other companies

  • Aggregate Paginated Project Run RecordsReplit · OA
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
  • Group AnagramsWorkday · PHONE SCREEN
  • Group AnagramsEPAM · PHONE SCREENEPAM interview questions
  • Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
  • Project and Filter Structured RecordsStripe · PHONE SCREENStripe interview questions
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
See Chime hiring insights
Saved
class Solution {
    public String[][] processCardCommands(String[][] operations) {
        // Write your code here.
    }
}
Checking account…