Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hayunjong83/0d28557117a4fe30b50c5760f9e06c3a to your computer and use it in GitHub Desktop.
Save hayunjong83/0d28557117a4fe30b50c5760f9e06c3a to your computer and use it in GitHub Desktop.
Minimum Time Visiting All Points
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