mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 08:21:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>在 MATLAB 中,有一个非常有用的函数 <code>reshape</code> ,它可以将一个 <code>m x n</code> 矩阵重塑为另一个大小不同(<code>r x c</code>)的新矩阵,但保留其原始数据。</p>\n\n<p>给你一个由二维数组 <code>mat</code> 表示的 <code>m x n</code> 矩阵,以及两个正整数 <code>r</code> 和 <code>c</code> ,分别表示想要的重构的矩阵的行数和列数。</p>\n\n<p>重构后的矩阵需要将原始矩阵的所有元素以相同的<strong> 行遍历顺序 </strong>填充。</p>\n\n<p>如果具有给定参数的 <code>reshape</code> 操作是可行且合理的,则输出新的重塑矩阵;否则,输出原始矩阵。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/04/24/reshape1-grid.jpg\" style=\"width: 613px; height: 173px;\" />\n<pre>\n<strong>输入:</strong>mat = [[1,2],[3,4]], r = 1, c = 4\n<strong>输出:</strong>[[1,2,3,4]]\n</pre>\n\n<p><strong>示例 2:</strong></p>\n<img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/04/24/reshape2-grid.jpg\" style=\"width: 453px; height: 173px;\" />\n<pre>\n<strong>输入:</strong>mat = [[1,2],[3,4]], r = 2, c = 4\n<strong>输出:</strong>[[1,2],[3,4]]\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 <= 100</code></li>\n\t<li><code>-1000 <= mat[i][j] <= 1000</code></li>\n\t<li><code>1 <= r, c <= 300</code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 295,
|
||||
"likes": 304,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"96.5K\", \"totalSubmission\": \"144.2K\", \"totalAcceptedRaw\": 96493, \"totalSubmissionRaw\": 144222, \"acRate\": \"66.9%\"}",
|
||||
"stats": "{\"totalAccepted\": \"101.9K\", \"totalSubmission\": \"152.9K\", \"totalAcceptedRaw\": 101913, \"totalSubmissionRaw\": 152943, \"acRate\": \"66.6%\"}",
|
||||
"hints": [
|
||||
"Do you know how 2d matrix is stored in 1d memory? Try to map 2-dimensions into one.",
|
||||
"M[i][j]=M[n*i+j] , where n is the number of cols. \r\nThis is the one way of converting 2-d indices into one 1-d index. \r\nNow, how will you convert 1-d index into 2-d indices?",
|
||||
|
Reference in New Issue
Block a user