Design a rules engine that flags business expenses and trips that violate spending policies.
Managers set spending policies on corporate cards so employees do not misuse them or exceed allowances. Each expense has fields such as expense_id, trip_id, amount_usd, expense_type, vendor_type and vendor_name. Implement evaluateRules(rules, expenses) to flag the expenses and trips that violate the rules. The return type is up to you; agree on it with the interviewer before coding. Example rules: no restaurant expense over 75; no airfare expenses; no entertainment expenses; no single expense over $250; a trip cannot exceed 2000 in total expenses; meal expenses cannot exceed 200 per trip. Rule types to support: bans (by expense_type, vendor_type or vendor_name), a maximum per expense, a trip total limit, an aggregate limit per expense_type, and a limit per vendor_type. More rule types will be added later and rules will be created through an API, so interviewers look for an extensible design that makes new rules easy to add, clean OOP, and good time and space complexity.
Expect follow-ups like
- Extend the rules engine to support trip-level rules.
Format · A coding round, as a phone screen or a later round, sometimes in person and sometimes with AI tools allowed. Candidates were encouraged to ask product questions, state assumptions and agree on the return type before coding.
Also asked as · Design a rules engine for a corporate credit card that flags expenses and trips violating spending policies.; Implement a rule evaluation engine that checks a list of expenses against business rules.; Design a business expense rules engine that applies expense-level rules.
Community answers
Related courses


