Skip to content

Commit c7a6129

Browse files
committed
Time: 4 ms (13.24%), Space: 44.1 MB (10.67%) - LeetHub
1 parent 140a5c2 commit c7a6129

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int minTimeToVisitAllPoints(int[][] points) {
3+
4+
int n= points.length;
5+
int ans =0;
6+
7+
for(int i=0; i<n-1; i++)
8+
{
9+
int deltaX = Math.abs(points[i+1][0] - points[i][0]);
10+
int deltaY = Math.abs(points[i+1][1] - points[i][1]);
11+
12+
ans += Math.min(deltaX,deltaY) + Math.abs(deltaX-deltaY);
13+
}
14+
15+
return ans;
16+
17+
}
18+
}

0 commit comments

Comments
 (0)