FastPrepCard Transaction Stream
Problems/Card Transaction Stream

Card Transaction Stream

Capital One logoCapital One● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A spring 2025 Capital One internship report lists two easy design interviews. The only exercise it names is a credit card one about card balances and transactions.

The report gives nothing more: no input format, kinds of transactions, decline rule, output or limits. Here a card's balance is the credit it can still spend. A charge goes through only on a known card and only up to its balance, which it then lowers. A declined charge leaves the balance as it was. A payment to a known card always goes through and raises the balance. A transaction on an unknown id is declined and changes nothing. The answer is one approved-or-declined flag per transaction. The text formats and all limits are our choice.

Overall, our version is about 40% the same as the reported question.

A card service holds several credit cards. Each card starts with a balance, the amount it can still spend. Transactions then come in one at a time, and each one is approved or declined as soon as it arrives.

cards[i] has the form "cardId balance": a card and its starting balance. transactions[j] has the form "charge cardId amount" or "payment cardId amount".

  • A charge goes through only if cardId belongs to one of the cards and amount is at most that card's current balance. Then the balance goes down by amount. A declined charge leaves the balance as it was.
  • A payment goes through if cardId belongs to one of the cards, and it raises that card's balance by amount.
  • Any transaction that names an id missing from cards is declined.

Go through the transactions in order. Return a boolean array where position j is true exactly when transactions[j] went through.

Function

approveTransactions(cards: String[], transactions: String[]) → boolean[]

Examples

Example 1

cards = ["c1 300","c2 50"]transactions = ["charge c1 120","charge c2 80","charge c1 180","charge c1 1"]return = [true,false,true,false]
  • c1 starts at 300. The charge of 120 fits, leaving 180.
  • c2 has only 50, so the charge of 80 is declined and c2 stays at 50.
  • The charge of 180 on c1 equals its balance, which is allowed, so it is approved and c1 drops to 0.
  • Now even a charge of 1 is too much for c1, so it is declined.

Example 2

cards = ["visa9 40"]transactions = ["charge visa9 70","payment visa9 50","charge visa9 70","charge visa9 25"]return = [false,true,true,false]
  • A charge of 70 is more than the starting 40, so it is declined.
  • The payment of 50 is approved and raises the balance to 90.
  • The same charge of 70 now fits, leaving 20.
  • The last charge of 25 is more than 20, so it is declined.

Example 3

cards = ["a 10","b 0"]transactions = ["payment zz 100","charge b 5","payment b 5","charge zz 1","charge b 5","charge a 10"]return = [false,false,true,false,true,true]
  • zz is not one of the cards, so both transactions that name it are declined: the payment of 100 and, later, the charge of 1. The payment does not create a card.
  • b starts with nothing, so its first charge of 5 is declined.
  • After the payment of 5, the same charge leaves b at 0 and is approved.
  • a spends its whole 10 in one approved charge.

Constraints

  • 1 <= cards.length <= 1000 and 1 <= transactions.length <= 2000
  • Every id, in cards or in transactions, is made of 1 to 12 characters from a-z and 0-9. No id appears twice in cards.
  • Each starting balance lies in [0, 10^9] and each amount in [1, 10^9].
  • Parts inside a string are separated by one space, and a number never begins with 0 unless it is 0 itself.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
  • Feature Flag Evaluation EngineCresta · ONSITE INTERVIEWCresta interview questions
  • Account Scheduler - Availability and AcquireStripe · ONSITE INTERVIEWStripe interview questions
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • In-Memory Spreadsheet ValuesRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Reference-Counted Deduplicating File SystemCitadel · PHONE SCREENCitadel interview questions
  • Design In-Memory File SystemSnowflake · PHONE SCREENSnowflake interview questions

Capital One interview experiences

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public boolean[] approveTransactions(String[] cards, String[] transactions) {
        // Write your code here.
    }
}
Checking account…