n sensors: sensor i stands at the point (xs[i], ys[i]). The distance between two sensors is measured in city blocks: |x₁ - x₂| + |y₁ - y₂|.
Find the pair of sensors i < j with the smallest distance and return [i, j]. If several pairs tie, return the lexicographically smallest one: the smaller i, and for equal i the smaller j.
Two sensors may stand at the same point. Trying all pairs in O(n²) is too slow for large n.xs=[0, 4, 2, 5], ys=[3, 1, 2, 4] → [0, 2]
Sensors 0 and 2: |0 - 2| + |3 - 2| = 3. Pair (1, 2) also gives 3, and every other pair is farther. Of the two pairs at distance 3, [0, 2] is lexicographically smaller.
xs=[1, 3, 1], ys=[2, 0, 2] → [0, 2]
Sensors 0 and 2 stand at the same point, so their distance is 0.
xs=[2, 0], ys=[0, 2] → [0, 1]
xs=[0, 4, 2, 5], ys=[3, 1, 2, 4]
[0, 2]
Run checks the first 3 tests in your browser. Submit checks all 87 tests on the server, hidden ones included.