当前位置:网站首页>【leetcode】48. Rotate image
【leetcode】48. Rotate image
2022-06-26 15:37:00 【liiiiiiiiiiiiike】
For details, please refer to 48. Rotated image
Their thinking :
- Rotate the image in place , You cannot use another matrix to rotate the image
- First flip the image horizontally , The first line and the last line exchange , The second line and the last line exchange , By analogy
- Next flip diagonally
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
""" Do not return anything, modify matrix in-place instead. """
# Rotate the image in place 90 degree , Do not use another matrix to rotate the image
# Double pointer
n = len(matrix)
# Flip horizontal
for i in range(n): # 0
left, right =0, n-1
while left <= right:
matrix[left][i], matrix[right][i] = matrix[right][i], matrix[left][i]
left += 1
right -= 1
# Turn diagonally
for i in range(n):
for j in range(i):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
Diagonal flip code !!!
for i in range(n):
for j in range(i):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
边栏推荐
- Cache page keepalive use in Vue
- How to handle 2gcsv files that cannot be opened? Use byzer
- How to load the contour CAD drawing of the engineering coordinate system obtained by the designer into the new earth
- [CEPH] cephfs internal implementation (I): Concept -- undigested
- 买股票通过券商经理的开户二维码开户资金是否安全?想开户炒股
- 数据库-视图
- 在哪个平台买股票开户安全?求指导
- # 粒子滤波 PF——三维匀速运动CV目标跟踪(粒子滤波VS扩展卡尔曼滤波)
- Smoothing data using convolution
- 刷题笔记(十九)--二叉树:二叉搜索树的修改与构造
猜你喜欢
![[tcapulusdb knowledge base] Introduction to tcapulusdb system management](/img/5a/28aaf8b115cbf4798cf0b201e4c068.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb system management
MySQL数据库基本SQL语句教程之高级操作

刷题笔记(十九)--二叉树:二叉搜索树的修改与构造
![[CEPH] cephfs internal implementation (I): Concept -- undigested](/img/5c/ca666118848b4f3042b834fb79d27f.png)
[CEPH] cephfs internal implementation (I): Concept -- undigested

feil_ The working directory on the left of uvission4 disappears

Evaluate:huggingface评价指标模块入门详细介绍

Lexin AWS IOT expresslink module achieves universal availability

【TcaplusDB知识库】TcaplusDB常规单据介绍
![[tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction](/img/05/8ec56393cac534cb5a00c10a1a9f32.png)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction

Redis cluster
随机推荐
Summary of students' learning career (2022)
【ceph】CEPHFS 内部实现(一):概念篇--未消化
AbortController的使用
一键安装gcc脚本
[tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction
【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
[file] VFS four structs: file, dentry, inode and super_ What is a block? difference? Relationship-- Editing
【问题解决】新版webots纹理等资源文件加载/下载时间过长
在哪个平台买股票开户安全?求指导
数据库-视图
如何配置使用新的单线激光雷达
[tcapulusdb knowledge base] tcapulusdb doc acceptance - transaction execution introduction
买股票通过券商经理的开户二维码开户资金是否安全?想开户炒股
Binding method of multiple sub control signal slots under QT
音视频学习(二)——帧率、码流和分辨率
English语法_形容词/副词3级 - 原级句型
Mongodb series window environment deployment configuration
Unity C # e-learning (VIII) -- www
Inaccurate data accuracy in ETL process
【ceph】mkdir|mksnap流程源码分析|锁状态切换实例