当前位置:网站首页>【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]
边栏推荐
- Audio and video learning (III) -- SIP protocol
- [graduation season · advanced technology Er] what is a wechat applet, which will help you open the door of the applet
- 10 minutes to understand bim+gis fusion, common BIM data formats and characteristics
- Restcloud ETL extracting dynamic library table data
- Is it safe to buy stocks and open accounts through the QR code of the securities manager? Want to open an account for stock trading
- 【文件】VFS四大struct:file、dentry、inode、super_block 是什么?区别?关系?--编辑中
- SAP GUI 770 Download
- 反射修改final
- Function: crypto JS encryption and decryption
- 手机上怎么开户?在线开户安全么?
猜你喜欢

AbortController的使用
![[tcapulusdb knowledge base] Introduction to tcapulusdb data structure](/img/64/4d7ec393d8469cdadc89078a8cf4b1.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb data structure

nanoPi Duo2连接wifi

10 minutes to understand bim+gis fusion, common BIM data formats and characteristics

【TcaplusDB知识库】TcaplusDB系统用户组介绍

How to load the contour CAD drawing of the engineering coordinate system obtained by the designer into the new earth

【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍

数据库-视图

【ceph】mkdir|mksnap流程源码分析|锁状态切换实例
Advanced operation of MySQL database basic SQL statement tutorial
随机推荐
HW安全响应
Compile configuration in file
JS之手写 bind、apply、call
Is it safe to open a stock account through the account opening link of the broker manager? Or is it safe to open an account in a securities company?
About selenium common. exceptions. Webdriverexception: message: an unknown server side error solution (resolved)
【ceph】CephFS 内部实现(四):MDS是如何启动的?--未消化
Unity unitywebrequest download package
English grammar_ Adjective / adverb Level 3 - original sentence pattern
A blog to thoroughly master the theory and practice of particle filter (PF) (matlab version)
Evaluate:huggingface detailed introduction to the evaluation index module
selenium将元素保存为图片
Beijing Fangshan District specialized special new small giant enterprise recognition conditions, with a subsidy of 500000 yuan
Is it safe to open an account for mobile stock registration? Is there any risk?
Applicable and inapplicable scenarios of mongodb series
5 figures illustrate the container network
【微信小程序】事件绑定,你搞懂了吗?
IDEA本地代理后,无法下载插件
/etc/profile、/etc/bashrc、~/. Bashrc differences
Smoothing data using convolution
【TcaplusDB知识库】TcaplusDB运维单据介绍