FastPrepIdentify Two Failing Tests From an Oracle Transcript

Identify Two Failing Tests From an Oracle Transcript

PhonePe logoPhonePe● MediumFULLTIMEONSITE INTERVIEW
Learn

Problem statement

Exactly two test IDs from 0 through testCount - 1 are failing. A captured oracle query returns failure exactly when both failing IDs are included in that query.

Given the queried ID subsets and their boolean failure responses, return the unique failing pair in increasing order. The transcript is guaranteed to identify exactly one pair.

Function

identifyFailingTests(testCount: int, queries: int[][], failedResponses: boolean[]) → int[]

Examples

Example 1

testCount = 2queries = [[0,1]]failedResponses = [true]return = [0,1]

Case 1 exercises the documented deterministic contract.

Example 2

testCount = 3queries = [[0,1],[0,2],[1,2]]failedResponses = [false,true,false]return = [0,2]

Case 2 exercises the documented deterministic contract.

Example 3

testCount = 4queries = [[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]failedResponses = [false,false,false,false,true,false]return = [1,3]

Case 3 exercises the documented deterministic contract.

Constraints

  • 2 <= testCount <= 100.
  • 1 <= queries.length == failedResponses.length <= 5000.
  • Each query contains unique valid IDs.

More PhonePe problems

See PhonePe hiring insights
public int[] identifyFailingTests(int testCount, int[][] queries, boolean[] failedResponses) {
    // Write your code here.
}
testCount2
queries[[0,1]]
failedResponses[true]
expected[0,1]
Checking account…