As reported: Rippling coding round on low-level design — a phone screen (Dec 2025), a CoderPad round for a Senior SWE (Jun 2025), and onsite round 3 of an SDE-2 loop in India (2025, offer). A company issues corporate credit cards; managers set policies so employees do not misuse the cards or exceed allowances. Build the rules engine:
evaluateRules(rules, expenses), where each expense is a dictionary of strings (expense_id,trip_id,amount_usd,expense_type,vendor_type,vendor_name), flagging the expenses and trips that break a rule. The return type is the candidate's to propose, discussed before coding; ask product questions and state assumptions. More rule types and rule creation through an API are coming, so the design must be easy to extend (model rules dynamically). Rule kinds in the round: ban anexpense_type,vendor_typeorvendor_name; a maximum per individual expense; a maximum per expense at one vendor type; a maximum trip total; a maximum total per expense type within a trip. Example policies: no restaurant expense above 75; no airfare; no entertainment; no expense over 250; no trip over 2000; meals per trip at most 200 (another round used: no expense over 175, restaurant at most 45, no entertainment).
Implement evaluateRules(rules, expenses).
Each expense is a map with string values:
{"expense_id": "001", "trip_id": "001", "amount_usd": "49.99",
"expense_type": "client_hosting", "vendor_type": "restaurant", "vendor_name": "Outback Roadhouse"}
Each rule is a string in one of five forms:
| Rule | Flags |
|---|---|
BAN <field> <value> (field is expense_type, vendor_type or vendor_name; the value may contain spaces) |
every expense whose field equals the value |
MAX_EXPENSE <amount> |
every expense with amount_usd > amount |
MAX_VENDOR_TYPE <vendor_type> <amount> |
every expense at that vendor type with amount_usd > amount |
MAX_TRIP_TOTAL <amount> |
every trip whose expenses sum to more than amount |
MAX_TRIP_EXPENSE_TYPE <expense_type> <amount> |
every trip whose expenses of that type sum to more than amount |
Return one string per violation, "<rule number> expense <expense_id>" or "<rule number> trip <trip_id>", with rules numbered from 1 in the given order. List the violations rule by rule; within a rule, expenses in input order and trips in the order their first expense appears.
Example
rules = ["BAN expense_type airfare", "BAN expense_type entertainment", "MAX_EXPENSE 250",
"MAX_VENDOR_TYPE restaurant 75", "MAX_TRIP_TOTAL 2000", "MAX_TRIP_EXPENSE_TYPE meals 200"]
expenses:
001 trip 001 49.99 client_hosting restaurant Outback Roadhouse
002 trip 001 80 meals restaurant Blue Fin
003 trip 001 450 lodging hotel Hilton
004 trip 002 320.10 airfare airline SkyJet
005 trip 002 130 meals cafe Bean Bar
006 trip 002 90.50 meals restaurant Taco Stand
007 trip 001 1500 lodging hotel Grand Inn
Output:
1 expense 004
3 expense 003
3 expense 004
3 expense 007
4 expense 002
4 expense 006
5 trip 001 (49.99 + 80 + 450 + 1500 = 2079.99)
6 trip 002 (meals: 130 + 90.50 = 220.50)
Constraints: at most 50 rules and 2·10^4 expenses; amounts are non-negative decimal strings with at most two decimals and at most 10^6; ids, types and vendor types contain no spaces or |.
Code runner format: line 1 the number of rules, then one rule per line, then the number of expenses, then one expense per line as expense_id|trip_id|amount_usd|expense_type|vendor_type|vendor_name. The harness builds the maps, calls evaluateRules, and prints one violation per line (none when there are none).
Clarifications
- Limits are inclusive: an amount or a sum equal to the limit is allowed.
- Compare money exactly:
49.99 + 150.01is exactly200.00, and0.10 + 0.20is not more than0.30. - An expense or trip that breaks several rules is listed once under each of them.