Amazon SDE-2 LLD round . Could not answer follow-up question. Inputs appreciated. !!

Anonymous User
507
Apr 02, 2026

Problem statement given

Design a simple rule engine that:

1.Takes a list of credit card expenses
2.Applies a set of rules
3.Flags the expenses that needs review
4.More rules can be added in future.
5.Design needs to be maintainable.

Example Rules
Restaurant expenses should not exceed 70 dollar.
Airfare expenses should not be allowed.
Any expense above 250 dollar should be flagged.

My Approach (Simple Version)

I modeled each rule as an independent unit and created a rule engine to execute them.

Each rule implements a common interface:

interface Rule {
    RuleResult evaluate(Expense expense);
}

The engine iterates through all expenses and applies all rules:

for each expense:
for each rule:
        evaluate rule
        if rule says SKIP → stop processing this expense
        if rule says FLAG → mark it
Finally, return all flagged expenses.

Followup question by interviewer was

If we keep adding more rules in the future, we’ll end up creating a new class for every rule.

👉 Won’t this lead to too many classes (class explosion)?
👉 How would you redesign this to keep it scalable and maintainable?

Would love to hear how others would approach this - especially in real-world systems.

Comments (2)