classSolution: defkWeakestRows(self, mat: List[List[int]], k: int) -> List[int]: m = len(mat)-1 n = len(mat[0])-1 list_ = [] for i inrange(m+1): soldier_num = 0 for j inrange(n+1): if mat[i][j]==1: soldier_num += 1 list_.append((i,soldier_num)) list_.sort(key=lambda x:x[1]) result = [] for ii in list_[:ii]: result.append(k[0]) return result