← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026Remote

Summary

Phone screen for a Software Engineer role at Google. One coding question on Quick Select, covering different approaches and pivot selection before implementing a solution.

Questions Asked (1)

Q1

Implement Quick Select. Walk through different approaches, discuss how you'd choose a pivot, then code up one of the methods.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

We spent a good chunk of time just talking through the tradeoffs before any code.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and constraints, then compare Quick Select with alternatives like sorting or heap-based selection. Explain pivot strategies and their trade-offs, then implement a clean, efficient solution with careful partitioning and edge-case handling.

Pro tip: Mention that while Quick Select has O(n) average time, its worst-case O(n²) can be avoided with randomized pivots or Median of Medians, but in practice randomized pivots are preferred for simplicity and speed. Also, discuss how to handle duplicates (e.g., three-way partitioning) to avoid worst-case behavior on repeated elements.

1. Clarify requirements and constraints

Ask about input size, data types, whether the array can be modified, and if duplicates are allowed. Confirm the expected time/space complexity and if worst-case guarantees are needed.

2. Discuss approaches and trade-offs

Compare sorting (O(n log n)), heap-based selection (O(n log k)), and Quick Select (O(n) average). Highlight Quick Select's in-place nature and average-case efficiency.

3. Explain pivot selection strategies

Cover first/last element, random pivot, median-of-three, and Median of Medians. Discuss their impact on performance and worst-case guarantees.

4. Implement Quick Select

Write code for a chosen method (e.g., randomized pivot) with a partition function. Handle edge cases like k out of bounds, empty array, and duplicates.

5. Analyze complexity and test

State average O(n) and worst-case O(n²) time, O(1) space. Walk through an example and discuss potential optimizations like three-way partitioning.

Key Points to Mention

  • Average-case O(n) time complexity and why it's faster than sorting for selection.
  • Pivot selection strategies: random pivot vs. median-of-three vs. Median of Medians.
  • Partitioning schemes: Lomuto vs. Hoare, and their trade-offs.
  • Handling duplicates with three-way partitioning to avoid O(n²) on repeated elements.
  • Worst-case O(n²) and how to mitigate it (randomization or Median of Medians).
  • In-place operation and O(1) extra space.

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