k closest points to origin
1import math
2
3class Solution:
4 def kClosest(self, points: List[List[int]], K: int) -> List[List[int]]:
5 return sorted(points, key=lambda x: math.sqrt(x[0]**2 + x[1]**2))[:K]
1import math
2
3class Solution:
4 def kClosest(self, points: List[List[int]], K: int) -> List[List[int]]:
5 return sorted(points, key=lambda x: math.sqrt(x[0]**2 + x[1]**2))[:K]