← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Junior

Junior
May 2026

Summary

PhD intern coding round at Google, one problem, the whole session was basically a deep dive on adaptive group testing with a black-box oracle. Felt like a research-flavored algo question dressed up as a coding interview.

Questions Asked (1)

Q1

You have N test items and a black-box function that returns true only if a given subset contains no bad pairs. Using as few calls to this function as possible, find all bad pairs among the N items.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I knew binary search had to be involved but my first instinct was just to test all pairs, which is O(N^2) and the interviewer's face said it all.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as finding all edges in a graph where vertices are items and edges are bad pairs, using subset queries that test if a subset is an independent set. Use a divide-and-conquer strategy to identify edges efficiently, leveraging binary search to isolate bad pairs. Aim for O(N log N) queries by recursively splitting the set and testing subsets.

Pro tip: Start by clarifying the query model and constraints (e.g., can you query any subset? Is the function monotonic?); then propose a solution with a clear complexity analysis, and discuss trade-offs between query count and computational overhead.

1. Clarify the problem and constraints

Confirm that the black-box function returns true iff the subset contains no bad pairs, and that we need to find all bad pairs with minimal calls. Ask about N's size and any assumptions (e.g., graph is sparse).

2. Model as graph edge discovery

Represent items as vertices and bad pairs as edges. The function tests if a subset is an independent set. The goal is to find all edges using independent set queries.

3. Design a divide-and-conquer algorithm

Recursively split the vertex set into two halves. For each half, test if it contains any bad pairs; if not, skip. To find edges across halves, use a binary search-like approach: for each vertex in one half, test subsets of the other half to identify its neighbors.

4. Analyze query complexity and optimize

Show that the algorithm uses O(N log N) queries in the worst case. Discuss potential improvements for sparse graphs, such as using group testing or adaptive splitting to reduce calls.

5. Discuss trade-offs and edge cases

Compare with naive O(N^2) approach. Mention handling of isolated vertices, complete graphs, and the impact of query cost. Consider if the function can be queried with large subsets efficiently.

Key Points to Mention

  • Graph representation: vertices as items, edges as bad pairs, independent set queries.
  • Divide-and-conquer strategy to isolate edges.
  • Binary search to find neighbors of a vertex within a subset.
  • Query complexity analysis: O(N log N) vs O(N^2).
  • Trade-offs between number of queries and computational overhead.
  • Handling of edge cases: no bad pairs, all pairs bad, sparse vs dense graphs.

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