Concurrent Volley Shot
Problem statement
A production shot(index) call may take between one and ten seconds and returns a boolean. All shots must start concurrently, and volleyShot completes with true as soon as any shot returns true; it returns false only after every shot has returned false.
For this deterministic judge adapter, latencies[i] is the completion time of shot i and results[i] is its returned value. Process completions in increasing latency order, breaking ties by smaller index, and return the volley result.
Function
volleyShot(latencies: int[], results: boolean[]) → booleanExamples
Example 1
latencies = [9000,1000,5000]results = [true,false,true]return = trueThe 1-second false completes first; the 5-second true completes the volley.
Example 2
latencies = [1000,2000,3000]results = [false,false,false]return = falseAll shots finish false.
Example 3
latencies = [7000]results = [true]return = trueThe only shot succeeds.
Constraints
1 <= latencies.length == results.length <= 100000.1 <= latencies[i] <= 10000milliseconds.