FastPrepTransaction Rule Expression Evaluator
Problems/Transaction Rule Expression Evaluator

Transaction Rule Expression Evaluator

Stripe logoStripe● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe onsite interview. The reports describe checking transaction conditions as true or false, AND and OR together, parentheses, and maybe a list of rules about card and merchant names. We cover about 75% of the details in the reported task. We chose the schema with four or six fields, names of one token, folding left to right with equal precedence, a deny when any rule denies, the exact output, the number limits and a limit on work. The original README for the AI round is not available. The report hedges with a word meaning "seems", so it does not settle how many items come in one batch or whether the interface is fixed.

Evaluate Boolean deny rules against transactions. Each transaction is a string row in either the original four-field form [id, amount, country, cardPresent] or the extended six-field form [id, amount, country, cardPresent, cardName, merchantName]. The two additional fields let a rule inspect the card and merchant names. Keep the input order.

A condition is field operator value. Fields are amount, country, cardPresent, cardName, and merchantName. String and Boolean fields support == and !=; amount also supports <, <=, >, and >=. Amounts in transaction rows are non-negative decimal integer strings; numeric rule literals may have a leading + or -. Compare their mathematical values exactly, including leading zeros.

Every rule is an expression separated only by ASCII whitespace: space, tab, carriage return, line feed, form feed, or vertical tab. A term is one condition or ( expression ). Parentheses are separate tokens. AND and OR have equal precedence: fold them from left to right within each parenthesized level. For example, country == US OR amount > 100 AND cardPresent == false means ( country == US OR amount > 100 ) AND cardPresent == false. A string literal is one non-empty token of ASCII letters, digits, underscores, or hyphens, with case-sensitive equality. Quoted strings and spaces inside values are outside this exercise.

Deny a transaction if any complete rule evaluates to true. Return one string id|DENY or id|ACCEPT for each transaction. If any rule refers to cardName or merchantName, every transaction uses six fields; otherwise four-field and six-field rows may be mixed. All inputs are valid, so missing fields and syntax errors need no output behavior.

Progressive practice

  1. Evaluate a single comparison to true or false.
  2. Combine conditions with left-to-right AND and OR.
  3. Add parentheses and reuse the parsed rules across transactions.

Function

evaluateTransactions(transactions: String[][], rules: String[]) → String[]

Examples

Example 1

transactions = [["t1","150","US","false"],["t2","40","CA","true"],["t3","70","US","true"]]rules = ["amount > 100 AND country == US","cardPresent == false AND amount >= 50"]return = ["t1|DENY","t2|ACCEPT","t3|ACCEPT"]

t1 matches both deny rules; the other transactions match neither.

Example 2

transactions = [["a","20","US","false"],["b","20","CA","false"]]rules = ["( country == US OR country == MX ) AND cardPresent == false"]return = ["a|DENY","b|ACCEPT"]

The nested country expression is true only for transaction a.

Example 3

transactions = [["c1","30","US","true","Visa","Cafe"],["c2","30","US","true","Amex","Cafe"],["c3","30","US","true","Visa","Market"]]rules = ["cardName == Visa AND merchantName == Cafe"]return = ["c1|DENY","c2|ACCEPT","c3|ACCEPT"]

Only c1 has both card name Visa and merchant name Cafe. c2 fails the card comparison, and c3 fails the merchant comparison.

Example 4

transactions = [["p","20","US","true"],["q","200","CA","false"]]rules = ["country == US OR amount > 100 AND cardPresent == false"]return = ["p|ACCEPT","q|DENY"]

For p, the first two comparisons fold to true, then true AND false is false. For q, false OR true is true, then true AND true is true. Equal precedence therefore accepts p and denies q.

Constraints

  • 1 <= transactions.length, rules.length <= 10000.
  • Every transaction has four or six fields as specified above; IDs are unique, non-empty ASCII strings without |.
  • Each amount has between 1 and 100 decimal digits. A numeric rule literal has between 1 and 100 decimal digits after its optional sign.
  • Country values are non-empty uppercase ASCII identifiers. Card and merchant names follow the single-token string-literal grammar; cardPresent is exactly true or false.
  • Every rule is syntactically valid with balanced parentheses and at most 200 whitespace-separated tokens.
  • The number of transactions multiplied by the total number of atomic conditions across all rules is at most 2000000.

More Stripe Onsite Interview questions

  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
  • Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
  • Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026
  • Merge and Filter Prioritized ConfigurationsONSITE INTERVIEW · Seen Apr 2026

Similar questions at other companies

  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Dictionary Records to an Editable XML TreeSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Split a Log Outside QuotesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Parse Command-Line TokensSamsara · ONSITE INTERVIEWSamsara interview questions
  • Parse, Validate, and Repair Markdown FormattingFigma · ONSITE INTERVIEWFigma interview questions
  • Parse and Query Server LogsKikoff · PHONE SCREENKikoff interview questions
  • CSV Row SerializerMercor · PHONE SCREENMercor interview questions
  • Host Log ParserVerkada · PHONE SCREENVerkada interview questions
  • Length-Prefixed String CodecSnowflake · PHONE SCREENSnowflake interview questions
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions

Interview reports that mention this question

  • Stripe AI Coding Interview, Experienced SWE: 6 Experiences

Stripe interview experiences

  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
  • Stripe SWE Intern Payout Scheduler Phone Screen: 1 Experience
  • Stripe New Grad SWE Onsite and HM Round: 1 Experience
  • Stripe Experienced MLE Phone Screens: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] evaluateTransactions(String[][] transactions, String[] rules) {
        // Write your code here.
    }
}
Checking account…