Skip to content

Commit cace31e

Browse files
authored
Create minimum-time-visiting-all-points.cpp
1 parent 1646256 commit cace31e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
int minTimeToVisitAllPoints(vector<vector<int>>& points) {
7+
int result = 0;
8+
for(int i = 0; i + 1 < points.size(); ++i) {
9+
result += max(abs(points[i + 1][1] - points[i][1]),
10+
abs(points[i + 1][0] - points[i][0]));
11+
}
12+
return result;
13+
}
14+
};

0 commit comments

Comments
 (0)