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

Posted
2 Apr 2026
210 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.

How it went

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.

Questions asked (1)

  1. 01

    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?

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Amazon recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

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