Minimum Time Visiting All Points

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
On a 2D plane, there are n points with integer coordinates points[i] = [x<sub>i</sub>, y<sub>i</sub>]. Return the minimum time in seconds to visit all the points in the order given by points.
You can move according to these rules:
In
1second, you can either:move vertically by one unit,
move horizontally by one unit, or
move diagonally
sqrt(2)units (in other words, move one unit vertically then one unit horizontally in1second).
You have to visit the points in the same order as they appear in the array.
You are allowed to pass through points that appear later in the order, but these do not count as visits.
LeetCode Problem - 1266
class Solution {
public int minTimeToVisitAllPoints(int[][] points) {
int answer = 0; // Initialize the total time to visit all points
// Iterate through the points array
for (int i = 0; i < points.length - 1; i++) {
int x1 = points[i][0]; // Get the x-coordinate of the current point
int y1 = points[i][1]; // Get the y-coordinate of the current point
int x2 = points[i + 1][0]; // Get the x-coordinate of the next point
int y2 = points[i + 1][1]; // Get the y-coordinate of the next point
// Calculate the time to move from the current point to the next point
// Time is determined by the maximum of the absolute differences in x and y coordinates
answer += Math.max(Math.abs(x2 - x1), Math.abs(y2 - y1));
}
return answer; // Return the total time to visit all points
}
}




