Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27b1c0c

Browse files
refactor 1341
1 parentc98ee43 commit27b1c0c

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

‎src/main/java/com/fishercoder/solutions/_1341.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,6 @@
44
importjava.util.Collections;
55
importjava.util.List;
66

7-
/**
8-
* 1341. The K Weakest Rows in a Matrix
9-
*
10-
* Given a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians),
11-
* return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest.
12-
* A row i is weaker than row j, if the number of soldiers in row i is less than the number of soldiers in row j,
13-
* or they have the same number of soldiers but i is less than j. Soldiers are always stand in the frontier of a row,
14-
* that is, always ones may appear first and then zeros.
15-
*
16-
* Example 1:
17-
* Input: mat =
18-
* [[1,1,0,0,0],
19-
* [1,1,1,1,0],
20-
* [1,0,0,0,0],
21-
* [1,1,0,0,0],
22-
* [1,1,1,1,1]],
23-
* k = 3
24-
* Output: [2,0,3]
25-
* Explanation:
26-
* The number of soldiers for each row is:
27-
* row 0 -> 2
28-
* row 1 -> 4
29-
* row 2 -> 1
30-
* row 3 -> 2
31-
* row 4 -> 5
32-
* Rows ordered from the weakest to the strongest are [2,0,3,1,4]
33-
*
34-
* Example 2:
35-
* Input: mat =
36-
* [[1,0,0,0],
37-
* [1,1,1,1],
38-
* [1,0,0,0],
39-
* [1,0,0,0]],
40-
* k = 2
41-
* Output: [0,2]
42-
* Explanation:
43-
* The number of soldiers for each row is:
44-
* row 0 -> 1
45-
* row 1 -> 4
46-
* row 2 -> 1
47-
* row 3 -> 1
48-
* Rows ordered from the weakest to the strongest are [0,2,3,1]
49-
*
50-
* Constraints:
51-
* m == mat.length
52-
* n == mat[i].length
53-
* 2 <= n, m <= 100
54-
* 1 <= k <= m
55-
* matrix[i][j] is either 0 or 1.
56-
* */
577
publicclass_1341 {
588
publicstaticclassSolution1 {
599
publicint[]kWeakestRows(int[][]mat,intk) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp