1072. Flip Columns For Maximum Number of Equal Rows Medium
1/**
2 * [1072] Flip Columns For Maximum Number of Equal Rows
3 *
4 * You are given an m x n binary matrix matrix.
5 * You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa).
6 * Return the maximum number of rows that have all values equal after some number of flips.
7 *
8 * Example 1:
9 *
10 * Input: matrix = [[0,1],[1,1]]
11 * Output: 1
12 * Explanation: After flipping no values, 1 row has all values equal.
13 *
14 * Example 2:
15 *
16 * Input: matrix = [[0,1],[1,0]]
17 * Output: 2
18 * Explanation: After flipping values in the first column, both rows have equal values.
19 *
20 * Example 3:
21 *
22 * Input: matrix = [[0,0,0],[0,0,1],[1,1,0]]
23 * Output: 2
24 * Explanation: After flipping values in the first two columns, the last two rows have equal values.
25 *
26 *
27 * Constraints:
28 *
29 * m == matrix.length
30 * n == matrix[i].length
31 * 1 <= m, n <= 300
32 * matrix[i][j] is either 0 or 1.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/
38// discuss: https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn max_equal_rows_after_flips(matrix: Vec<Vec<i32>>) -> i32 {
44 0
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_1072() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.