Leetcode1266. Minimum Time Visiting All Points

int minTimeToVisitAllPoints public (int [] [] Points) { 
int = rowLength points.length; // get the number of rows
int COUNT = 0;
for (int I = 0; I <rowLength -. 1; I ++) {
int min = -1 ; // defined between the abscissa and ordinate minimum
int rowdif = Math.abs (points [i ] [0] - points [i + 1] [0]); // a difference between the coordinate value row
int coldif = Math.abs (points [i] [ 1] - points [i + 1] [1]); // difference between the left column
if (rowdif> coldif) {// difference between ranks whichever is smaller ramp step is to take the number of steps
min = coldif;
} the else {
min = rowdif;
}
COUNT = COUNT + + min the Math.abs (rowdif - coldif);
}
// System.out.println ( "the Total Time =" + COUNT + "seconds the");
return COUNT;
}
my speed is not fast solution

 

 

 

Well my two values ​​is actually the maximum difference in the two pairs

Guess you like

Origin www.cnblogs.com/chengxian/p/12204022.html