The Verbal Script Template
When you transition from "Thinking" to "Implementing," use this script:
"I have a brute force idea that would take $O(n^2)$ time by checking all pairs. However, I can optimize this to $O(n \log n)$ by sorting the input first. Does that sound like a good direction to pursue?"
Why This Works
- Confidence: You show you understand complexity.
- Collaboration: You involve the interviewer.
- Safety: You don't waste 20 minutes coding the wrong thing.
Leading the Conversation
If the interviewer stays quiet, give them a Progress Update:
- "I'm currently implementing the base cases for the recursion..."
- "I'm using a HashMap here to store the character counts so we can achieve linear time..."
- "I'm going to run a quick dry run to make sure my pointers don't go out of bounds..."
Handling Errors (The "Oops" Recovery)
If you find a bug:
- Don't: Silently delete code and panic.
- Do: "Ah, I just realized my loop condition
i < nmight cause an index out of bounds error if the array is empty. Let me add a check for that."