Google | Phone screen round | L3 Level

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-10-10Added By Anonymous
Source: Link

Company: Google
Role: l3
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

You have N unit tests that pass if run separately. But there are several pairs of tests that, if run in a single test set, fail the whole set (e.g. because they modify a global state in a non-hermetic db). Your task is to find any such pair.

You are given a function runTests(i1, i2, i3, ...) that takes a subset of tests, executes them in a single set and returns true if the whole set passes.

You can also assume that all minimal sets of tests that fail are made up of a pair of tests (i.e. if runTests(s) fails, with len(s) > 2, then there exists a strict subset t of s such that runTests(t) also fails).

Can someone please help to get the approach better than O(N^2)
Note - runTests(s) this function also have a complexity = len(s)

Comments