Who Gets the Catch?

  • + 0 comments
    # For those who are still struggling to pass all test cases:
    def whoGetsTheCatch(n, x, X, V):
        minTime = 10**10
        for i in range(n):
            dis = abs(X[i]-x)
            time = dis/V[i]
            if time < minTime:
                minTime = time
                index = i
                count = 0           
            if minTime == time:
                count +=1       
        if count > 1:
            return -1
        else:
            return index