Extend an Expense Rules Engine with Nested Boolean Conditions
Company: Rippling
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: hard
Interview Round: Technical Screen
Extend an expense rules engine to support nested AND, OR, and NOT conditions. Explain how you would represent, validate, and evaluate expressions such as:
- restaurant AND meals AND amount greater than 50;
- (entertainment AND amount greater than 100) OR client-hosting;
- amount greater than 100 AND NOT vendor-name equals a specified supplier.
### Constraints & Assumptions
The source makes composite rules a discussion extension. Treat the examples as predicates over expense fields and define which field each business term refers to. Rules arrive as data through an API; never evaluate them as arbitrary code.
### Clarifying Questions
Which fields and operators are supported? How are missing fields handled? Is an empty AND or OR valid? What limits apply to tree depth and rule size? Do composites filter individual expenses before group aggregation?
### What a Strong Answer Covers
A typed expression tree, explicit boolean semantics, validation at rule creation, extensible leaf evaluation, and explainable violations.
### Follow-up Questions
How would short-circuiting affect explanation output? How do you introduce a new operator safely? What tests distinguish NOT of a compound expression from negating each child separately?
Overview: Extend an expense rules engine with validated AND/OR/NOT expression trees, typed leaf operators, explicit missing-field semantics, and explainable evaluation.
Extend an expense rules engine to support nested AND, OR, and NOT conditions. Explain how you would represent, validate, and evaluate expressions such as:
restaurant AND meals AND amount greater than 50;
(entertainment AND amount greater than 100) OR client-hosting;
amount greater than 100 AND NOT vendor-name equals a specified supplier.
Constraints & Assumptions
The source makes composite rules a discussion extension. Treat the examples as predicates over expense fields and define which field each business term refers to. Rules arrive as data through an API; never evaluate them as arbitrary code.
Clarifying Questions Guidance
Which fields and operators are supported? How are missing fields handled? Is an empty AND or OR valid? What limits apply to tree depth and rule size? Do composites filter individual expenses before group aggregation?
What a Strong Answer Covers Guidance
A typed expression tree, explicit boolean semantics, validation at rule creation, extensible leaf evaluation, and explainable violations.
Follow-up Questions Guidance
How would short-circuiting affect explanation output? How do you introduce a new operator safely? What tests distinguish NOT of a compound expression from negating each child separately?