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)/旋转矩阵 [rotate-matrix-lcci].html

46 lines
898 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>给你一幅由 <code>N × N</code> 矩阵表示的图像,其中每个像素的大小为 4 字节。请你设计一种算法,将图像旋转 90 度。</p>
<p>不占用额外内存空间能否做到?</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<pre>
给定 <strong>matrix</strong> =
[
[1,2,3],
[4,5,6],
[7,8,9]
],
<strong>原地</strong>旋转输入矩阵,使其变为:
[
[7,4,1],
[8,5,2],
[9,6,3]
]
</pre>
<p><strong>示例 2:</strong></p>
<pre>
给定 <strong>matrix</strong> =
[
[ 5, 1, 9,11],
[ 2, 4, 8,10],
[13, 3, 6, 7],
[15,14,12,16]
],
<strong>原地</strong>旋转输入矩阵,使其变为:
[
[15,13, 2, 5],
[14, 3, 4, 1],
[12, 6, 8, 9],
[16, 7,10,11]
]
</pre>
<p><strong>注意</strong>:本题与主站 48 题相同<a href="https://leetcode-cn.com/problems/rotate-image/">https://leetcode-cn.com/problems/rotate-image/</a></p>