first and second of the same length. The gap of a pair of indices i and j is
|first[i] - first[j]| + |second[i] - second[j]| + |i - j|.
Return the largest gap over all pairs 0 ≤ i, j < len(first).
Checking every pair takes O(n²); try to find a linear solution.first=[3, -1, 4], second=[0, 2, -2] → 10
Indices 1 and 2: |-1 - 4| + |2 - (-2)| + |1 - 2| = 5 + 4 + 1 = 10.
first=[5, 5], second=[7, 7] → 1
The values are equal, so only the index distance counts: 1.
first=[3, -1, 4], second=[0, 2, -2]
10
Run checks the first 3 tests in your browser. Submit checks all 95 tests on the server, hidden ones included.