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

amazon logo
amazon
April 2, 2026 · 0 reads

Summary

I interviewed for an SDE‑2 role and was asked to design a simple rule engine for credit‑card expenses; I was unable to answer the follow‑up scalability question.

Full Experience

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.

Interview Questions (1)

1.

Design a Simple Rule Engine for Expense Validation

System Design

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 dollars.
  • Airfare expenses should not be allowed.
  • Any expense above 250 dollars should be flagged.

Follow‑up scalability question: If we keep adding more rules, we’ll end up creating a new class for every rule. Won’t this lead to class explosion? How would you redesign this to keep it scalable and maintainable?

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!