Leetcode 973. K Closest Points to Origin
作者:互联网
送分题
class Solution(object): def kClosest(self, points, K): """ :type points: List[List[int]] :type K: int :rtype: List[List[int]] """ dst, ret = {}, [] for i, val in enumerate(points): dst[i] = val[0] ** 2 + val[1] ** 2 dst = sorted(dst.items(), key=lambda d:d[1]) for key,val in dst: ret.append(points[key]) return ret[:K]
标签:Origin,973,val,int,dst,List,ret,Points,points 来源: https://www.cnblogs.com/zywscq/p/10543956.html