105. The K Weakest Rows in a Matrix

Return the indices of the k weakest rows in a matrix. A row's strength is the number of ones before the first zero.
Example 1
Input: mat = [[1,0,0,0],[1,1,1,1],[1,0,0,0],[1,0,0,0]], k = 2
Output: [0,2]
Explanation: Rows 0 and 2 each have one soldier.
Example 2
Input: 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
Output: [2,0,3]
Explanation: Rows 2, 0, and 3 are the weakest.
arraysheapmedium
JavaScript
Loading...
Line 1, Char 1