标签:weak sorted print http self range com mic __name__
class Solution(object):
def kWeakestRows(self, mat, k):
"""
:type mat: List[List[int]]
:type k: int
:rtype: List[int]
"""
power = [sum(line) for line in mat]
return sorted(list(range(len(mat))), key=lambda i: (power[i], i), reverse=False)[:k]
if __name__ == ‘__main__‘:
solution = Solution()
print(
solution.kWeakestRows(mat=[[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],
k=3))
标签:weak sorted print http self range com mic __name__
原文地址:https://www.cnblogs.com/panweiwei/p/13065318.html