PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Coding & Algorithms/Google

Minimize calls to find all bad test pairs

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in algorithm design and query complexity, focusing on adaptive group-testing, combinatorial search, and reasoning about information-theoretic bounds for identifying defective test pairs.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Minimize calls to find all bad test pairs

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You have \(n\) atomic tests \(t_1, t_2, \dots, t_n\). You are given access to a black-box function: ```python bool runTest(set<Test> S) ``` which behaves as follows: - `runTest(S) == True` if the subset \(S\) contains **no** incompatible (bad) pair of tests. - `runTest(S) == False` if the subset \(S\) contains **at least one** incompatible (bad) pair of tests. There is some unknown set of unordered **bad pairs** \((t_i, t_j)\), where \(i \ne j\). You do **not** know in advance which pairs are bad or how many bad pairs there are. Your goal is to discover **all** bad pairs while making as few calls to `runTest` as possible. You may adaptively choose each subset \(S\) based on the results of previous calls. ### Tasks 1. Design an algorithm that, using only calls to `runTest`, finds **all** bad pairs \((t_i, t_j)\). 2. Analyze the number of calls to `runTest` your algorithm requires, as a function of: - \(n\): the total number of tests, and - \(k\): the total number of bad pairs. 3. Argue why your algorithm is correct (i.e., why it will eventually find every bad pair and not report any good pair as bad). You do not need to provide full production code, but describe the algorithm clearly enough that it could be implemented.

Quick Answer: This question evaluates a candidate's competency in algorithm design and query complexity, focusing on adaptive group-testing, combinatorial search, and reasoning about information-theoretic bounds for identifying defective test pairs.

Related Interview Questions

  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Solve Shortest Paths and Rental Allocation - Google (medium)
  • Solve Two Array Optimization Problems - Google (medium)
Google logo
Google
Nov 5, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0

You have nnn atomic tests t1,t2,…,tnt_1, t_2, \dots, t_nt1​,t2​,…,tn​.

You are given access to a black-box function:

bool runTest(set<Test> S)

which behaves as follows:

  • runTest(S) == True if the subset SSS contains no incompatible (bad) pair of tests.
  • runTest(S) == False if the subset SSS contains at least one incompatible (bad) pair of tests.

There is some unknown set of unordered bad pairs (ti,tj)(t_i, t_j)(ti​,tj​), where i≠ji \ne ji=j. You do not know in advance which pairs are bad or how many bad pairs there are.

Your goal is to discover all bad pairs while making as few calls to runTest as possible. You may adaptively choose each subset SSS based on the results of previous calls.

Tasks

  1. Design an algorithm that, using only calls to runTest , finds all bad pairs (ti,tj)(t_i, t_j)(ti​,tj​) .
  2. Analyze the number of calls to runTest your algorithm requires, as a function of:
    • nnn : the total number of tests, and
    • kkk : the total number of bad pairs.
  3. Argue why your algorithm is correct (i.e., why it will eventually find every bad pair and not report any good pair as bad).

You do not need to provide full production code, but describe the algorithm clearly enough that it could be implemented.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.