We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b40e92a commit 0c52921Copy full SHA for 0c52921
solution/0900-0999/0973.K Closest Points to Origin/Solution.go
@@ -1,7 +1,6 @@
1
func kClosest(points [][]int, k int) [][]int {
2
sort.Slice(points, func(i, j int) bool {
3
- a, b := points[i], points[j]
4
- return a[0]*a[0]+a[1]*a[1] < b[0]*b[0]+b[1]*b[1]
+ return math.Hypot(float64(points[i][0]), float64(points[i][1])) < math.Hypot(float64(points[j][0]), float64(points[j][1]))
5
})
6
return points[:k]
7
-}
+}
0 commit comments