Skip to main content
All Questions

Design a rules engine that flags business expenses and trips that violate spending policies.

Unlock detailed company stats for this questionUpgrade

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

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.