← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Got a Google SWE interview that was purely algorithmic, one problem about finding all bad pairs among a set of tests using a black-box oracle function. Pretty niche problem, not your typical LeetCode grind.

Questions Asked (1)

Q1

You have n atomic tests and a black-box function that returns true if a given subset contains no incompatible test pairs, and false otherwise. Design an algorithm to find all bad (incompatible) pairs using as few calls to this function as possible, analyze the call complexity in terms of n and k (number of bad pairs), and argue correctness.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a minute to even parse what they were asking.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as finding all edges in a hidden graph where vertices are tests and edges are bad pairs, using a group testing oracle that checks if a subset is independent. Use a divide-and-conquer strategy to recursively split the set of tests and identify bad pairs, aiming for O(k log n) calls. Analyze the recurrence and prove correctness by induction on the recursion tree.

Pro tip: Emphasize that the oracle is monotone: if a set is clean, all its subsets are clean. This allows pruning and ensures that when a set is clean, you can stop recursing, which is key to achieving O(k log n) calls.

1. Model as a graph problem

Represent tests as vertices and bad pairs as edges. The oracle tells whether a given vertex subset is an independent set (contains no edges).

2. Design divide-and-conquer algorithm

Recursively split the current set of vertices into two halves. For each half, call the oracle; if it returns true, the half is clean and we stop. If false, recurse on that half. When a set of size 2 is dirty, the pair is bad.

3. Analyze call complexity

Derive a recurrence: T(n) = 2T(n/2) + O(1) for dirty sets, but clean sets terminate early. Show that each bad edge contributes O(log n) calls along the recursion path, leading to O(k log n) total calls.

4. Argue correctness

Prove by induction that the algorithm finds exactly all bad pairs: any bad pair must be separated at some recursion level and detected when the subset of size 2 is tested; clean sets are never recursed into, so no false positives.

5. Discuss optimizations and trade-offs

Mention potential improvements like using larger branching factors or adaptive splitting to reduce calls further, and compare with naive O(n^2) pairwise testing.

Key Points to Mention

  • Monotonicity of the oracle: if a set is clean, all subsets are clean.
  • Divide-and-conquer recursion with early termination for clean sets.
  • Complexity analysis: O(k log n) calls, where k is the number of bad pairs.
  • Correctness proof by induction on the recursion tree.
  • Comparison with naive approach: O(n^2) calls vs O(k log n).
  • Handling of edge cases: k=0 (all clean), k large (dense graph).

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