We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77314ab commit 625443fCopy full SHA for 625443f
solution/1072.Flip Columns For Maximum Number of Equal Rows/Solution.java
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ public int maxEqualRowsAfterFlips(int[][] matrix) {
3
+ Map<String, Integer> map = new HashMap<>();
4
+ for (int[] row : matrix) {
5
+ if (row[0] == 1) {
6
+ for (int i = 0; i < row.length; ++i) {
7
+ row[i] ^= 1;
8
+ }
9
10
+ StringBuilder sb = new StringBuilder();
11
+ for (int x : row) {
12
+ sb.append(x);
13
14
+ String s = sb.toString();
15
+ map.put(s, map.getOrDefault(s, 0) + 1);
16
17
+ return map.values().stream().max(Integer::compareTo).get();
18
19
+}
0 commit comments