Corporate Card Expense Rules
Updated
Problem statement
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 withvendorType = RESTAURANTmay not exceed$75.NO_AIRFARE: an expense withexpenseType = AIRFAREis not allowed.NO_ENTERTAINMENT: an expense withexpenseType = ENTERTAINMENTis 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 withexpenseType = MEALon 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
expenseIdis unique. amountUsdis a non-negative integer string.
More Rippling Phone Screen questions
- Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
- Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
- Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
- In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
- Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026
- Delivery Cost TrackerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Recipe Rating ServiceNubank · PHONE SCREEN
- Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Transactional Key-Value StoreGrammarly · ONSITE INTERVIEW
- LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheAthenahealth · PHONE SCREEN
- Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- File System Shell CommandsHarvey · ONSITE INTERVIEWHarvey interview questions
- Paged KV Cache AccessNVIDIA · PHONE SCREENNVIDIA interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
Interview reports that mention this question
- Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
- Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
- Rippling SWE Screens and Loops: 31 Experiences (Part 1 of 3)
- Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
- Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
- Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)