파비의 매일매일 공부기록

2023.12.03 Today's Challenge 본문

Problem Solving/LeetCode

2023.12.03 Today's Challenge

fabichoi 2023. 12. 3. 23:45

https://leetcode.com/problems/minimum-time-visiting-all-points/

 

Minimum Time Visiting All Points - LeetCode

Can you solve this real interview question? Minimum Time Visiting All Points - On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi]. Return the minimum time in seconds to visit all the points in the order given by points. You can

leetcode.com

쉬운 문제긴 했음

class Solution:
    def minTimeToVisitAllPoints(self, points: List[List[int]]) -> int:
        ans = 0
        for i in range(len(points) - 1):
            curr_x, curr_y = points[i]
            target_x, target_y = points[i+1]
            ans += max(abs(target_x - curr_x), abs(target_y - curr_y))
        return ans
반응형

'Problem Solving > LeetCode' 카테고리의 다른 글

2023.12.05 Today's Challenge  (0) 2023.12.05
2023.12.04 Today's Challenge  (1) 2023.12.04
2023.12.02 Today's Challenge  (1) 2023.12.02
2023.12.01 Today's Challenge  (0) 2023.12.01
2023.11.30 Today's Challenge  (0) 2023.11.30
Comments