Skip to content

Commit

Permalink
Create 1266_Minimum_Time_Visiting_All_Points.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhuzaima committed Dec 4, 2023
1 parent fd3b980 commit b767951
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 1266_Minimum_Time_Visiting_All_Points.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// id: 1266
// Name: Minimum Time Visiting All Points
// link: https://leetcode.com/problems/minimum-time-visiting-all-points/
// Difficulty: Easy

class Solution {
public int minTimeToVisitAllPoints(int[][] points) {
int result = 0;

for (int i = 1; i < points.length; i++) {
result += Math.max(Math.abs(points[i][0] - points[i-1][0]), Math.abs(points[i][1] - points[i-1][1]));
}
return result;
}
}

0 comments on commit b767951

Please sign in to comment.