|
1 | 1 | [#0861-score-after-flipping-matrix] |
2 | | -= 861. Score After Flipping Matrix |
| 2 | += 861. 翻转矩阵后的得分 |
3 | 3 |
|
4 | | -{leetcode}/problems/score-after-flipping-matrix/[LeetCode - Score After Flipping Matrix^] |
| 4 | +https://leetcode.cn/problems/score-after-flipping-matrix/[LeetCode - 861. 翻转矩阵后的得分^] |
5 | 5 |
|
6 | | -We have a two dimensional matrix `A` where each value is `0` or `1`. |
| 6 | +给你一个大小为 `m x n` 的二元矩阵 `grid` ,矩阵中每个元素的值为 `0` 或 `1`。 |
7 | 7 |
|
8 | | -A move consists of choosing any row or column, and toggling each value in that row or column: changing all `0`s to `1`s, and all `1`s to `0`s. |
| 8 | +一次 *移动* 是指选择任一行或列,并转换该行或列中的每一个值:将所有 `0` 都更改为 `1`,将所有 `1` 都更改为 `0`。 |
9 | 9 |
|
10 | | -After making any number of moves, every row of this matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. |
| 10 | +在做出任意次数的移动后,将该矩阵的每一行都按照二进制数来解释,矩阵的 *得分* 就是这些数字的总和。 |
11 | 11 |
|
12 | | -Return the highest possible score. |
| 12 | +在执行任意次 *移动* 后(含 0 次),返回可能的最高分数。 |
13 | 13 |
|
14 | | - |
| 14 | +*示例 1:* |
15 | 15 |
|
| 16 | +image::images/0861-01.jpg[{image_attr}] |
16 | 17 |
|
| 18 | +.... |
| 19 | +输入:grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]] |
| 20 | +输出:39 |
| 21 | +解释:0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39 |
| 22 | +.... |
17 | 23 |
|
| 24 | +*示例 2:* |
18 | 25 |
|
| 26 | +.... |
| 27 | +输入:grid = [[0]] |
| 28 | +输出:1 |
| 29 | +.... |
19 | 30 |
|
20 | | -*Example 1:* |
21 | | - |
22 | | -[subs="verbatim,quotes,macros"] |
23 | | ----- |
24 | | -*Input:* [[0,0,1,1],[1,0,1,0],[1,1,0,0]] |
25 | | -*Output:* 39 |
26 | | -*Explanation:* |
27 | | -Toggled to [[1,1,1,1],[1,0,0,1],[1,1,1,1]]. |
28 | | -0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39 |
29 | | ----- |
30 | | - |
31 | | - |
32 | | - |
33 | | -*Note:* |
| 31 | +*提示:* |
34 | 32 |
|
35 | | - |
36 | | -. `1 <= A.length <= 20` |
37 | | -. `1 <= A[0].length <= 20` |
38 | | -. `A[i][j]` is `0` or `1`. |
| 33 | +* `m == grid.length` |
| 34 | +* `n == grid[i].length` |
| 35 | +* `1 \<= m, n \<= 20+` |
| 36 | +* `grid[i][j]` 为 `0` 或 `1` |
39 | 37 |
|
40 | 38 |
|
41 | 39 |
|
| 40 | +== 思路分析 |
42 | 41 |
|
43 | 42 |
|
44 | 43 | [[src-0861]] |
| 44 | +[tabs] |
| 45 | +==== |
| 46 | +一刷:: |
| 47 | ++ |
| 48 | +-- |
45 | 49 | [{java_src_attr}] |
46 | 50 | ---- |
47 | 51 | include::{sourcedir}/_0861_ScoreAfterFlippingMatrix.java[tag=answer] |
48 | 52 | ---- |
| 53 | +-- |
| 54 | +
|
| 55 | +// 二刷:: |
| 56 | +// + |
| 57 | +// -- |
| 58 | +// [{java_src_attr}] |
| 59 | +// ---- |
| 60 | +// include::{sourcedir}/_0861_ScoreAfterFlippingMatrix_2.java[tag=answer] |
| 61 | +// ---- |
| 62 | +// -- |
| 63 | +==== |
| 64 | + |
| 65 | + |
| 66 | +== 参考资料 |
49 | 67 |
|
| 68 | +. https://leetcode.cn/problems/score-after-flipping-matrix/solutions/512802/jiu-ying-suan-tong-su-yi-dong-mei-xiang-fgt9j/[861. 翻转矩阵后的得分 - 就硬算,通俗易懂,一开始没想到位操作^] |
| 69 | +. https://leetcode.cn/problems/score-after-flipping-matrix/solutions/512323/fan-zhuan-ju-zhen-tan-xin-xin-lu-li-chen-21h7/[861. 翻转矩阵后的得分 - 翻转矩阵贪心心路历程!^] |
| 70 | +. https://leetcode.cn/problems/score-after-flipping-matrix/solutions/511825/fan-zhuan-ju-zhen-hou-de-de-fen-by-leetc-cxma/[861. 翻转矩阵后的得分 - 官方题解^] |
0 commit comments