Published on May 7, 2025by Claudio Teixeira
A structured two-phase approach for algorithm interviews: CLARIFY (PRD) to understand requirements and PROPOSE (SRD) to design and analyze solutions.
1. Introduction
Phase 1: CLARIFY (The "PRD")
- Goal: "So, the goal is to ___. For input X, you want Y?"
- Inputs: "What are the constraints? (Size, type, range?)"
- Outputs: "What format for the output? (Type, value?)"
- Edges: "How to handle empty/null/no-solution cases?"
- Assumptions: "Okay, so I'll assume ___ and ___."
Phase 2: PROPOSE (The "SRD")
Plan A (Brute-force/Simple)
"My first thought is a simple approach: [describe in 5-10 words]."
Plan B (Better)
"To optimize, I'll use a [Data Structure: Hash Map]. The plan is:
- Step 1: [e.g., Build frequency map]
- Step 2: [e.g., Find first char with count 1]"
Analyze
- Time(efficiency): "This will be O(...) because ___." *time complexity (optimal: constant/logarithmic; bad: liner)
- Space(memory): "This will use O(...) space for ___." *space complexity (optimal: low space in memory: constant; bad: high space in memory)