stops strictly in the order listed, where stops[i] = [x, y]. It starts at the first point.
Each second the robot moves one cell in any of eight directions: horizontally, vertically or diagonally, like a king in chess. It may pass through points whose turn has not come yet, but that does not count as visiting them.
Return the fewest seconds the robot needs to visit every point.stops=[[0, 0], [3, 1], [3, -2]] → 6
To (3, 1): one diagonal step and two to the right, 3 seconds. Then three steps down to (3, -2), 3 more. 6 in total.
stops=[[2, 2], [2, 2], [-1, 5]] → 3
The second stop coincides with the first and costs nothing. Then 3 diagonal steps.
stops=[[7, -4]] → 0
stops[i] holds exactly two numbersstops=[[0, 0], [3, 1], [3, -2]]
6
Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.