Backend Engineering
Senior
system_design
How would you implement a rules engine to enforce the corporate credit card expense policies, specifically to ensure that no expenses at a restaurant exceed $75 and total meal expenses cannot exceed $200 per trip? Please describe your approach in detail.
## Approach
1. Set up a microservice architecture to handle expenses submission.
2. Utilize a relational database (e.g., PostgreSQL) to store expenses and rules.
3. Implement validation logic for each rule as per requirements (e.g., using if-else conditions or a rules engine).
4. Return appropriate messages for valid and invalid expense submissions.
## Complexity
**Time:** O(n), where n is the number of rules checked.
**Space:** O(m), where m is the number of expenses stored in the database.
## Trade-offs
- Straightforward implementation vs. using a more complex rules management system.
Trusted by 100+ professionals preparing for interviews
Trusted by 100+ professionals
50+ Company Question Banks
5+ Supported Languages
Practice More Questions Like This
Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.
Get Started Free