1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/转置矩阵 [transpose-matrix].html

34 lines
1016 B
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<p>给你一个二维整数数组 <code>matrix</code>, 返回 <code>matrix</code><strong>转置矩阵</strong></p>
<p>矩阵的 <strong>转置</strong> 是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引。</p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2021/02/10/hint_transpose.png" style="width: 600px; height: 197px;" /></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>matrix = [[1,2,3],[4,5,6],[7,8,9]]
<strong>输出:</strong>[[1,4,7],[2,5,8],[3,6,9]]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>matrix = [[1,2,3],[4,5,6]]
<strong>输出:</strong>[[1,4],[2,5],[3,6]]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 <= m, n <= 1000</code></li>
<li><code>1 <= m * n <= 10<sup>5</sup></code></li>
<li><code>-10<sup>9</sup> <= matrix[i][j] <= 10<sup>9</sup></code></li>
</ul>