From b767951e4899ac634bfab65b15758df73ef0d395 Mon Sep 17 00:00:00 2001 From: Muhammad Khuzaima Umair Date: Mon, 4 Dec 2023 23:33:05 +0500 Subject: [PATCH] Create 1266_Minimum_Time_Visiting_All_Points.java --- 1266_Minimum_Time_Visiting_All_Points.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 1266_Minimum_Time_Visiting_All_Points.java diff --git a/1266_Minimum_Time_Visiting_All_Points.java b/1266_Minimum_Time_Visiting_All_Points.java new file mode 100644 index 0000000..c1b4e21 --- /dev/null +++ b/1266_Minimum_Time_Visiting_All_Points.java @@ -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; + } +} +