Skip to content

Commit b40e92a

Browse files
authored
Update Solution.cpp
1 parent 9395fb6 commit b40e92a

File tree

1 file changed

+3
-3
lines changed
  • solution/0900-0999/0973.K Closest Points to Origin

1 file changed

+3
-3
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Solution {
22
public:
33
vector<vector<int>> kClosest(vector<vector<int>>& points, int k) {
4-
sort(points.begin(), points.end(), [](const vector<int>& a, const vector<int>& b) {
5-
return a[0] * a[0] + a[1] * a[1] < b[0] * b[0] + b[1] * b[1];
4+
sort(points.begin(), points.end(), [](const vector<int>& p1, const vector<int>& p2) {
5+
return hypot(p1[0], p1[1]) < hypot(p2[0], p2[1]);
66
});
77
return vector<vector<int>>(points.begin(), points.begin() + k);
88
}
9-
};
9+
};

0 commit comments

Comments
 (0)