FastPrepFind a Failing Test Pair
Problems/Find a Failing Test Pair

Find a Failing Test Pair

Google logoGoogle● MediumFULLTIMEONSITE INTERVIEW

Updated Dec 2026

QuestionExamples

Problem statement

Source note: Reported in a Google L4 software engineer onsite interview. Each test passes on its own, but some pairs break when run together, and a helper says whether a range of tests breaks. The task was to find one broken pair with as few helper calls as possible.

The report gives no limits, no example and no rule for which pair to return. Here, tests are numbered from 0, a range is a run of consecutive tests, and you get the broken pairs as input so that one fixed answer can be checked: the pair found by first looking for the shortest breaking prefix and then the shortest breaking range that ends where that prefix ends. The editorial teaches the search with few helper calls.

Our version is about 80% the same as the reported question.

Given n tests and the list pairs of test pairs that fail when they run together, return the failing pair [l, r] that the range search described below finds.

The tests are numbered from 0 to n - 1, and each test passes when it runs alone. pairs[i] = [a, b] means that tests a and b fail when both of them run.

The oracle fails(l, r) runs tests l through r, both included, together. It returns true exactly when that range holds both tests of at least one pair in pairs.

The problem statement continues
Pro

Examples

Example 1

n = 8pairs = [[4,6],[1,5],[3,5],[0,7]]return = [3,5]

fails(0, 4) is false because no pair lies inside tests 0 to 4. fails(0, 5) is true because [1, 5] and [3, 5] lie inside, so r = 5. fails(3, 5) is true because of [3, 5], and fails(4, 5) is false, so l = 3.

02 · Example 2
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week

More Google Onsite Interview questions

  • Count Winning Dice Face PairsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Cars for Rental RequestsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Search in a Rotated Sorted ArrayAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEWByteDance interview questions
  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Smallest Batch Size Within a Step LimitMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Peak of an Increasing-Then-Decreasing ArraySnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEWUber interview questions
  • Search a 2D MatrixWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Search in Rotated Sorted ArrayKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Find First and Last Position in Sorted ArrayPaytm · ONSITE INTERVIEWPaytm interview questions
  • Detect a Silent SensorConfluent · ONSITE INTERVIEWConfluent interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
CodePython 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import heapq
from collections import defaultdict
 
class Solution:
def solve(self, values, queries):
# Build the adjacency structure
n = len(values)
graph = defaultdict(list)
for u, v in queries:
graph[u].append(v)
 
best = [float("inf")] * n
heap = [(0, 0)]
while heap:
cost, node = heapq.heappop(heap)
if cost > best[node]:
continue
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week