Skip to content

Commit 73f6e15

Browse files
authored
Create Row With Maximum Ones.java
1 parent 5201ec2 commit 73f6e15

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Easy/Row With Maximum Ones.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int[] rowAndMaximumOnes(int[][] mat) {
3+
int maxOnes = 0;
4+
int maxOnesRow = 0;
5+
for (int i = 0; i < mat.length; i++) {
6+
int oneCount = 0;
7+
for (int num : mat[i]) {
8+
oneCount += num == 1 ? 1 : 0;
9+
}
10+
if (oneCount > maxOnes) {
11+
maxOnes = oneCount;
12+
maxOnesRow = i;
13+
}
14+
}
15+
return new int[]{maxOnesRow, maxOnes};
16+
}
17+
}

0 commit comments

Comments
 (0)