Created
January 11, 2021 06:41
-
-
Save hayunjong83/0d28557117a4fe30b50c5760f9e06c3a to your computer and use it in GitHub Desktop.
Minimum Time Visiting All Points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int minTimeToVisitAllPoints(vector<vector<int>>& points) { | |
int time = 0; | |
for(int i = 1; i < points.size() ; i++) | |
{ | |
int x, y, m; | |
x = abs(points[i-1][0] - points[i][0]); | |
y = abs(points[i-1][1] - points[i][1]); | |
m = min(x, y); | |
time += x + y - m; | |
} | |
return time ; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment