Corporate Card Expense Rules
Learn this problemProblem 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 problems
- Delivery Cost TrackerPHONE SCREEN · Seen Jul 2026
- Camel CardsPHONE SCREEN · Seen May 2026
- Article Vote TrackerPHONE SCREEN · Seen May 2026
- Employee Resource Access ManagementONSITE INTERVIEW · Seen Jan 2026
- Limit an Organization Tree's HeightONSITE INTERVIEW · Seen Aug 2025
- Distributed System RecoveryOA · Seen Jul 2025
- Server Upgrade PlanningOA · Seen Jul 2025
- Shortest SubstringOA · Seen Jul 2025