[Algorithm] 15 week(4.18 ~ 4.24) 2/3

Dev_min·2022년 4월 20일
0

algorithm

목록 보기
48/157

1266. Minimum Time Visiting All Points

var minTimeToVisitAllPoints = function(points) {
    let result = 0;
    for(let i = 0; i < points.length - 1; i++){
        const x = Math.abs(points[i][0] - points[i+1][0]);
        const y = Math.abs(points[i][1] - points[i+1][1]);
        
        result += Math.max(x, y);
    }
    
    return result;
};
profile
TIL record

0개의 댓글