UMPIRE is a structured 6-step framework that prevents you from "freezing" when given any unfamiliar problem.
graph LR
U[U: Understand] --> M[M: Match Pattern]
M --> P[P: Plan Approach]
P --> I[I: Implement Code]
I --> R[R: Review & Dry-Run]
R --> E[E: Evaluate Big-O]
- Restate the problem in your own words to the interviewer.
- Ask 2–3 clarifying questions:
- Edge cases: empty array, single element, negative numbers, duplicates?
-
Constraints: How large is
$N$ ? ($N \le 10^5 \implies \mathcal{O}(N \log N)$ or $\mathcal{O}(N)$). - Output format: return indices or values? In-place or new data structure?
- Write down 1–2 concrete input/output examples.
- What classic pattern does this problem resemble?
- Which data structure fits? (Hash Map for
$\mathcal{O}(1)$ lookups, Two Pointers for sorted arrays, Deque for sliding window, Heap for Top-K).
- Always state the Brute Force first: Describe the naive idea and state its complexity explicitly ($\mathcal{O}(N^2)$).
- Propose the Optimal Optimization: Explain how the chosen pattern eliminates redundant work.
- Confirm the plan with the interviewer before writing a single line of code!
- Write clean, modular Python 3 code with descriptive variable names (
slow,fast,left,rightinstead ofi,j). - Add concise comments on non-trivial steps.
- Modularize helpers when appropriate.
- Step through your code with a small example on paper (dry run).
- Verify off-by-one errors and pointer bounds.
- State the final Time and Space Complexity explicitly using Big-O.
- Discuss follow-up optimizations (e.g. streaming data, memory constraints).