Corporate Card Expense Rules
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The MEAL_LIMIT rule is what trips people up in the Rippling corporate card expense question, reported in September 2026. It looks like a plain validation loop, then trip-level rules show up and every expense on a trip has to carry the violation. The interviewer also pushes on extensibility, so the code has to be clean as well as correct. If you're taking this OA soon, the pattern is hash-table aggregation plus an ordered rule list. StealthCoder is the safety net if you blank on the live OA, but the logic here is simple enough to hold in your head.
The problem
Evaluate corporate-card expenses against individual-expense and whole-trip policies. Expense Format Each row is [expenseId, tripId, amountUsd, expenseType, vendorType, vendorName]. Amounts are non-negative integer USD values. IDs and categorical values are case-sensitive. Policy Rules RESTAURANT_LIMIT: an expense with vendorType = RESTAURANT may not exceed $75. NO_AIRFARE: an expense with expenseType = AIRFARE is not allowed. NO_ENTERTAINMENT: an expense with expenseType = ENTERTAINMENT is not allowed. EXPENSE_LIMIT: no individual expense may exceed $250. TRIP_LIMIT: the sum of all expenses on one trip may not exceed $2000. MEAL_LIMIT: the sum of expenses with expenseType = MEAL on one trip may not exceed $200. Output Return one row per expense in input order. The first value is the expense ID. Append every violated rule code in the policy order above. If the expense violates no rule, return only its ID. A trip-level violation is attached to every expense belonging to that trip. Interviewer follow-ups The interviewer asked candidates to design the rule API so new per-expense and per-trip rules could be added without rewriting the evaluator. Reports also mention discussing validation order, rule composition, and how the return model should expose multiple violations. Function evaluateExpenseRules(expenses: String[][]) → String[][] Examples Example 1 expenses = [["e1","trip1","80","MEAL","RESTAURANT","Bistro"],["e2","trip1","130","MEAL","CAFE","Coffee"],["e3","trip2","300","AIRFARE","AIRLINE","Sky"]] return = [["e1","RESTAURANT_LIMIT","MEAL_LIMIT"],["e2","MEAL_LIMIT"],["e3","NO_AIRFARE","EXPENSE_LIMIT"]] Trip 1 spends $210 on meals, so both trip expenses receive MEAL_LIMIT. Expense e1 also exceeds the restaurant cap. Expense e3 is airfare and exceeds $250. Example 2 expenses = [["a","trip9","1000","LODGING","HOTEL","North"],["b","trip9","1100","LODGING","HOTEL","South"],["c","trip10","50","MEAL","RESTAURANT","Deli"]] return = [["a","EXPENSE_LIMIT","TRIP_LIMIT"],["b","EXPENSE_LIMIT","TRIP_LIMIT"],["c"]] Trip 9 totals $2100, and both expenses also exceed the individual limit. Expense c passes every rule. Constraints 1 <= expenses.length <= 100000 Each expenseId is unique. amountUsd is a non-negative integer string.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Do two passes. First pass: group by tripId and compute two sums, total spend and MEAL-only spend, in hash maps. Second pass: for each expense in input order, check rules in the fixed policy order: RESTAURANT_LIMIT, NO_AIRFARE, NO_ENTERTAINMENT, EXPENSE_LIMIT, TRIP_LIMIT, MEAL_LIMIT. Append codes as they fail. The common pitfall is output order. Example 1 lists RESTAURANT_LIMIT before MEAL_LIMIT, and Example 2 lists EXPENSE_LIMIT before TRIP_LIMIT. Another pitfall is using >= instead of >, since the limits are inclusive. For the follow-up, define two rule interfaces, one per-expense and one per-trip with precomputed aggregates, and keep them in one ordered list. Return a list of codes per expense. If you freeze mid-OA, StealthCoder can give you the structure while you keep control of the submission. With 100000 rows, this is O(n).
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Corporate Card Expense Rules cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Corporate Card Expense Rules FAQ
What's the trick in the Rippling corporate card expense problem?+
Precompute per-trip totals first. Sum all spend per tripId and sum MEAL spend per tripId in hash maps. Then walk expenses in input order and check each rule. Trip-level violations go on every expense in that trip, so you can't decide them row by row in one pass.
How hard is this question really?+
Easy on algorithm, medium on care. There's no tricky data structure. The points are lost on rule ordering, inclusive limits (exactly $75 or $250 passes), and forgetting that a trip violation applies to all of its expenses, including small ones.
What order should violation codes appear in?+
Policy order as listed: RESTAURANT_LIMIT, NO_AIRFARE, NO_ENTERTAINMENT, EXPENSE_LIMIT, TRIP_LIMIT, MEAL_LIMIT. Evaluate in that sequence and append as you go, so you never need to sort. Both examples confirm this ordering.
How do I handle the extensible rule API follow-up?+
Define a per-expense rule (takes an expense, returns a code or nothing) and a per-trip rule (takes the trip's aggregates, returns a code or nothing). Keep them in one ordered list. Adding a rule means adding an entry, not editing the evaluator. Mention this out loud.
How do I prepare for this in 48 hours?+
Write the two-pass solution once from scratch and test it against both examples. Then sketch the rule interface. Practice grouping with hash maps and parsing amounts from strings. Edge cases to check: amount 0, exactly 2000 total, exactly 200 meals, and a trip with one expense.