mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 15:01:40 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个大小为 <code>m x n</code> 的整数矩阵 <code>mat</code> 和一个整数 <code>target</code> 。</p>\n\n<p>从矩阵的 <strong>每一行</strong> 中选择一个整数,你的目标是 <strong>最小化</strong> 所有选中元素之 <strong>和</strong> 与目标值 <code>target</code> 的 <strong>绝对差</strong> 。</p>\n\n<p>返回 <strong>最小的绝对差</strong> 。</p>\n\n<p><code>a</code> 和 <code>b</code> 两数字的 <strong>绝对差</strong> 是 <code>a - b</code> 的绝对值。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/08/03/matrix1.png\" style=\"width: 181px; height: 181px;\" /></p>\n\n<pre>\n<strong>输入:</strong>mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13\n<strong>输出:</strong>0\n<strong>解释:</strong>一种可能的最优选择方案是:\n- 第一行选出 1\n- 第二行选出 5\n- 第三行选出 7\n所选元素的和是 13 ,等于目标值,所以绝对差是 0 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/08/03/matrix1-1.png\" style=\"width: 61px; height: 181px;\" /></p>\n\n<pre>\n<strong>输入:</strong>mat = [[1],[2],[3]], target = 100\n<strong>输出:</strong>94\n<strong>解释:</strong>唯一一种选择方案是:\n- 第一行选出 1\n- 第二行选出 2\n- 第三行选出 3\n所选元素的和是 6 ,绝对差是 94 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/08/03/matrix1-3.png\" style=\"width: 301px; height: 61px;\" /></p>\n\n<pre>\n<strong>输入:</strong>mat = [[1,2,9,8,7]], target = 6\n<strong>输出:</strong>1\n<strong>解释:</strong>最优的选择方案是选出第一行的 7 。\n绝对差是 1 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>m == mat.length</code></li>\n\t<li><code>n == mat[i].length</code></li>\n\t<li><code>1 <= m, n <= 70</code></li>\n\t<li><code>1 <= mat[i][j] <= 70</code></li>\n\t<li><code>1 <= target <= 800</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\": \"5.3K\", \"totalSubmission\": \"16.9K\", \"totalAcceptedRaw\": 5285, \"totalSubmissionRaw\": 16943, \"acRate\": \"31.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.4K\", \"totalSubmission\": \"17.2K\", \"totalAcceptedRaw\": 5365, \"totalSubmissionRaw\": 17153, \"acRate\": \"31.3%\"}",
|
||||
"hints": [
|
||||
"The sum of chosen elements will not be too large. Consider using a hash set to record all possible sums while iterating each row.",
|
||||
"Instead of keeping track of all possible sums, since in each row, we are adding positive numbers, only keep those that can be a candidate, not exceeding the target by too much."
|
||||
|
Reference in New Issue
Block a user