← Goldman Sachs Interview Insights

Goldman Sachs·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Goldman Sachs SWE coding round, one meaty question about extending a fraud rules engine with MCC blocklists. More design-heavy than I expected for what looked like a pure coding problem.

Questions Asked (1)

Q1

You have a fraud rules engine that evaluates transactions. Extend it to reject any transaction whose merchant category code (MCC) appears in a global blocklist, and also reject transactions where the MCC appears in a per-user blocklist (keyed by user ID). The function signature should stay the same, and the design should be extensible for future rule types.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

I spent the first few minutes just coding the lookup logic and almost missed the whole point.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a design that uses a rule interface or strategy pattern to encapsulate each rule, with a composite rule that evaluates all rules. For the MCC blocklists, use efficient data structures like hash sets for O(1) lookups, and ensure the design allows adding new rule types without modifying the core engine.

Pro tip: Emphasize the importance of keeping the function signature unchanged to avoid breaking existing callers, and discuss how the rule engine can be extended via configuration or dependency injection. Also, mention the need for thread safety and performance considerations in a high-throughput fraud detection system.

1. Clarify Requirements and Constraints

Ask questions to understand the expected scale, latency requirements, and whether the blocklists can be updated dynamically. Confirm that the function signature must remain the same and that extensibility is a key goal.

2. Design the Rule Abstraction

Define a Rule interface with a method like 'evaluate(Transaction)' that returns a boolean or a result. Each rule (global MCC blocklist, per-user MCC blocklist) implements this interface.

3. Implement the Composite Rule Engine

Create a RuleEngine that holds a list of rules and evaluates them in order, rejecting the transaction if any rule triggers. This allows adding new rules without changing the engine's core logic.

4. Optimize Data Structures for Blocklists

Use a Set for the global MCC blocklist for O(1) lookups. For per-user blocklists, use a Map<UserId, Set<MCC>> to efficiently check if a user's MCC is blocked.

5. Discuss Extensibility and Trade-offs

Explain how new rule types can be added by implementing the Rule interface and registering them with the engine. Discuss trade-offs like rule ordering, performance overhead, and potential caching strategies.

Key Points to Mention

  • Strategy pattern or rule interface to encapsulate individual rules
  • Composite pattern to combine multiple rules and evaluate them uniformly
  • Use of hash sets for O(1) MCC lookup in global and per-user blocklists
  • Maintaining the same function signature by injecting the rule engine as a dependency
  • Extensibility: adding new rules without modifying existing code (Open/Closed Principle)
  • Performance considerations: thread safety, caching, and avoiding unnecessary lookups

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.