mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-02 14:12:17 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个 <code>n x n</code> 的二进制网格 <code>grid</code>,每一次操作中,你可以选择网格的 <strong>相邻两行</strong> 进行交换。</p>\n\n<p>一个符合要求的网格需要满足主对角线以上的格子全部都是 <strong>0</strong> 。</p>\n\n<p>请你返回使网格满足要求的最少操作次数,如果无法使网格符合要求,请你返回 <strong>-1</strong> 。</p>\n\n<p>主对角线指的是从 <code>(1, 1)</code> 到 <code>(n, n)</code> 的这些格子。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/08/02/fw.jpg\" style=\"height: 141px; width: 750px;\"></p>\n\n<pre><strong>输入:</strong>grid = [[0,0,1],[1,1,0],[1,0,0]]\n<strong>输出:</strong>3\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/08/02/e2.jpg\" style=\"height: 270px; width: 270px;\"></p>\n\n<pre><strong>输入:</strong>grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]\n<strong>输出:</strong>-1\n<strong>解释:</strong>所有行都是一样的,交换相邻行无法使网格符合要求。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/08/02/e3.jpg\" style=\"height: 210px; width: 210px;\"></p>\n\n<pre><strong>输入:</strong>grid = [[1,0,0],[1,1,0],[1,1,1]]\n<strong>输出:</strong>0\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == grid.length</code></li>\n\t<li><code>n == grid[i].length</code></li>\n\t<li><code>1 <= n <= 200</code></li>\n\t<li><code>grid[i][j]</code> 要么是 <code>0</code> 要么是 <code>1</code> 。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 42,
|
||||
"likes": 43,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.4K\", \"totalSubmission\": \"9.9K\", \"totalAcceptedRaw\": 4440, \"totalSubmissionRaw\": 9916, \"acRate\": \"44.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"4.5K\", \"totalSubmission\": \"10K\", \"totalAcceptedRaw\": 4474, \"totalSubmissionRaw\": 10013, \"acRate\": \"44.7%\"}",
|
||||
"hints": [
|
||||
"For each row of the grid calculate the most right 1 in the grid in the array maxRight.",
|
||||
"To check if there exist answer, sort maxRight and check if maxRight[i] ≤ i for all possible i's.",
|
||||
|
Reference in New Issue
Block a user