Mock Coding Interview Simulation
📖 Concept
Mock interviews are the most effective preparation method. Simulating real interview conditions builds comfort, timing, and communication skills.
How to run an effective mock:
- Set the environment: Plain text editor (no autocomplete), 45-minute timer, webcam on
- Think aloud: Narrate your entire thought process. Don't go silent.
- Follow the framework: Understand → Plan → Code → Test → Optimize
- Get feedback: After the mock, review: communication clarity, time management, code quality, edge cases
Timing breakdown for a 45-min round:
0-3 min: Read problem, ask clarifying questions
3-8 min: Discuss approach, state complexity
8-30 min: Code the solution
30-38 min: Test with examples and edge cases
38-45 min: Discuss optimizations, follow-up questions
Common follow-up questions:
- "Can you do this in O(1) space?"
- "What if the input doesn't fit in memory?"
- "How would you parallelize this?"
- "What if the input is streaming (online algorithm)?"
Communication tips for senior candidates:
- Lead the conversation — don't wait for prompts
- State trade-offs — "I can do O(n) time with O(n) space, or O(n log n) with O(1) space"
- Acknowledge complexity — "This is an NP-hard problem, so I'll use an approximation"
- Discuss alternatives — "Another approach would be X, but I chose Y because..."
💻 Code Example
1// Mock interview example: Design an iterator for a 2D matrix2// that traverses in spiral order34// Step 1: Understand — I need to traverse a matrix in spiral order5// and return elements one at a time via next() and hasNext()67// Step 2: Plan — Pre-compute the spiral order in the constructor,8// then iterate through the precomputed list. Alternative: maintain9// boundaries and compute on-the-fly (more complex but O(1) space).1011// Step 3: Code12class SpiralIterator(matrix: Array<IntArray>) : Iterator<Int> {13 private val elements = mutableListOf<Int>()14 private var index = 01516 init {17 if (matrix.isNotEmpty() && matrix[0].isNotEmpty()) {18 var top = 019 var bottom = matrix.size - 120 var left = 021 var right = matrix[0].size - 12223 while (top <= bottom && left <= right) {24 // Right25 for (col in left..right) elements.add(matrix[top][col])26 top++27 // Down28 for (row in top..bottom) elements.add(matrix[row][right])29 right--30 // Left31 if (top <= bottom) {32 for (col in right downTo left) elements.add(matrix[bottom][col])33 bottom--34 }35 // Up36 if (left <= right) {37 for (row in bottom downTo top) elements.add(matrix[row][left])38 left++39 }40 }41 }42 }4344 override fun hasNext(): Boolean = index < elements.size45 override fun next(): Int {46 if (!hasNext()) throw NoSuchElementException()47 return elements[index++]48 }49}5051// Step 4: Test52// Input: [[1,2,3],[4,5,6],[7,8,9]]53// Expected: 1,2,3,6,9,8,7,4,554// Edge: empty matrix → hasNext() = false55// Edge: single row → 1,2,356// Edge: single column → 1,4,75758// Step 5: Discuss59// Time: O(m*n) constructor, O(1) next/hasNext60// Space: O(m*n) for stored elements61// Trade-off: Could compute on-the-fly with O(1) space but more complex
🏋️ Practice Exercise
Mock Interview Schedule (Weekly):
- Monday: Solve 2 medium problems with timer (35 min each)
- Tuesday: Solve 1 hard problem (45 min)
- Wednesday: System design practice (45 min)
- Thursday: Solve 2 medium problems from different categories
- Friday: Full mock interview with a partner
- Weekend: Review all solutions from the week, identify weak patterns
Self-assessment after each mock:
- Did I identify the pattern within 3 minutes?
- Did I discuss my approach before coding?
- Was my code clean and idiomatic Kotlin?
- Did I handle edge cases without prompting?
- Did I stay within the time limit?
- Did I communicate clearly throughout?
⚠️ Common Mistakes
Practicing with autocomplete and syntax highlighting — Google interviews use Google Docs or a simple editor
Not timing yourself — without time pressure, you can't assess if your pace is interview-ready
Practicing solo only — pair mock interviews are 10x more effective because they test communication
Only practicing easy problems — Google asks medium to hard problems, practice at that level
💼 Interview Questions
🎤 Mock Interview
Mock interview is powered by AI for Mock Coding Interview Simulation. Login to unlock this feature.