k
개를 잘라라 반환function kWeakestRows(mat: number[][], k: number): number[] {
const weakest = Array.from({ length: mat.length }, (_, i) => i)
const soldierRow = mat.map(line => line.filter(Boolean).length)
const sorted = weakest.toSorted((a, b) => soldierRow[a] - soldierRow[b])
return sorted.slice(0, k)
};