GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/973_K_Closest_Points_to_Origin.py at master · qiyuangong/leetcode Expand file tree/ Copy path973_K_Closest_Points_to_Origin.pyMore file actions 13 lines (12 loc) · 421 Bytes / Copy path973_K_Closest_Points_to_Origin.pyFile metadata and controls13 lines (12 loc) · 421 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution(object): # def kClosest(self, points, K): # """ # :type points: List[List[int]] # :type K: int # :rtype: List[List[int]] # """ # # Sort # return sorted(points, key=lambda x: x[0] ** 2 + x[1] ** 2)[:K] def kClosest(self, points, K): # K smallest heaq return heapq.nsmallest(K, points, key=lambda x: x[0] ** 2 + x[1] ** 2) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |