-
Notifications
You must be signed in to change notification settings - Fork 161
/
transpose-matrix.md
35 lines (25 loc) · 1.01 KB
/
transpose-matrix.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<p>Given a matrix <code>A</code>, return the transpose of <code>A</code>.</p>
<p>The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.</p>
<br>
<img src="https://assets.leetcode.com/uploads/2019/10/20/hint_transpose.png" width="700"/>
<p> </p>
<div>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-1-1">[[1,2,3],[4,5,6],[7,8,9]]</span>
<strong>Output: </strong><span id="example-output-1">[[1,4,7],[2,5,8],[3,6,9]]</span>
</pre>
<div>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong><span id="example-input-2-1">[[1,2,3],[4,5,6]]</span>
<strong>Output: </strong><span id="example-output-2">[[1,4],[2,5],[3,6]]</span>
</pre>
<p> </p>
<p><span><strong>Note:</strong></span></p>
<ol>
<li><code><span>1 <= A.length <= 1000</span></code></li>
<li><code><span>1 <= A[0].length <= 1000</span></code></li>
</ol>
</div>
</div>