Minimum Time Visiting All Points LeetCode solution in Java

1
class Solution {
2
public int minTimeToVisitAllPoints(int[][] points) {
3
int max = 0, x, y;
4
for (int i = 0; i < points.length - 1; i++) {
5
for (int j = 0; j < points[i].length - 1; j++) {
6
x = Math.abs(points[i][j] - points[i + 1][j]);
7
y = Math.abs(points[i][j + 1] - points[i + 1][j + 1]);
8
max += Math.max(x, y);
9
}
10
}
11
return max;
12
}
13
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0