LeetCode --- 1337. The K Weakest Rows in a Matrix 解题报告
Posted 杨鑫newlfe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1337. The K Weakest Rows in a Matrix 解题报告相关的知识,希望对你有一定的参考价值。
You are given an m x n
binary matrix mat
of 1
\'s (representing soldiers) and 0
\'s (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1
\'s will appear to the left of all the 0
\'s in each row.
A row i
is weaker than a row j
if one of the following is true:
- The number of soldiers in row
i
is less than the number of soldiers in rowj
. - Both rows have the same number of soldiers and
i < j
.
Return the indices of the k
weakest rows in the matrix ordered from weakest to strongest.
Example 1:
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
以上是关于LeetCode --- 1337. The K Weakest Rows in a Matrix 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode --- 1337. The K Weakest Rows in a Matrix 解题报告
LeetCode Algorithm 1337. 矩阵中战斗力最弱的 K 行
Python描述 LeetCode 1337. 矩阵中战斗力最弱的 K 行