【Leetcode】【python】Rotate Image
来源:互联网 发布:python 可变参数 编辑:程序博客网 时间:2024/06/05 18:27
题目大意
顺时针翻转数组(以图像存储为例)
解题思路
转置+翻转
代码
class Solution(object): def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ for i in range(len(matrix)): # 列长度 for j in range(i+1, len(matrix)): # 行只需要遍历右上矩阵 matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] for i in range(len(matrix)): # 翻转 matrix[i].reverse()
总结
用到内置的reverse()了,算不算犯规呢
阅读全文
0 0
- 【Leetcode】【python】Rotate Image
- 【LeetCode with Python】 Rotate Image
- 【LeetCode】【Python题解】Rotate Image
- 48. Rotate Image Leetcode Python
- 【LEETCODE】48-Rotate Image [Python]
- LeetCode--Rotate Image(旋转图像)Python
- LeetCode: Rotate Image
- [Leetcode] Rotate Image
- LeetCode : Rotate Image
- [LeetCode] Rotate Image
- leetcode 67: Rotate Image
- [leetcode] Rotate Image
- [Leetcode] Rotate Image
- [LeetCode]Rotate Image
- LeetCode-Rotate Image
- [leetcode] Rotate Image
- LeetCode - Rotate Image
- leetcode之Rotate Image
- 搭建服务器上的GIT并实现自动同步到站点目录(www)
- redis在windows下安装和PHP中使用
- windows下php7安装redis扩展
- sequential container overview(C++ 容器简介)
- 【Leetcode】【python】Permutations II
- 【Leetcode】【python】Rotate Image
- FTPrep, 95 Unique Binary Search Trees II, TODO: a little confused
- Java基础语法
- FTPrep, 96 Unique Binary Search Trees
- TWO
- 欢迎使用CSDN-markdown编辑器
- 死亡
- 面向对象
- 第二章 SQL命令参考-ALTER CONVERSION