leetCode 48.Rotate Image (旋转图像) 解题思路和方法
来源:互联网 发布:网络玄幻小说合集chm 编辑:程序博客网 时间:2024/05/21 13:23
Rotate Image
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
思路:其实就是旋转数组,没有什么难度,代码如下:
public class Solution { public void rotate(int[][] matrix) { int[][] a = new int[matrix.length][matrix.length]; //实现深拷贝 for(int i = 0; i < matrix.length; i++){ for(int j = 0; j < matrix.length;j++){ a[i][j] = matrix[i][j]; } } //数据旋转 for(int i = 0; i < a[0].length; i++){ int k = 0; for(int j = a.length-1; j >=0; j--){ matrix[i][k++] = a[j][i]; //System.out.print(a[j][i] + " "); } //System.out.println(""); } }}
0 0
- leetCode 48.Rotate Image (旋转图像) 解题思路和方法
- Leetcode #48. Rotate Image 图像旋转 解题报告
- LeetCode Rotate Image旋转图像
- [LeetCode] Rotate Image 旋转图像
- LeetCode Rotate Image旋转图像
- leetcode解题之48. Rotate Image java版(旋转图像)
- leetCode 61.Rotate List (旋转链表) 解题思路和方法
- LeetCode | Rotate Image(旋转图像)
- leetcode之图像旋转(Rotate Image)
- LeetCode 48 Rotate Image(旋转图像)
- LeetCode--Rotate Image(旋转图像)Python
- Rotate Image 旋转图像
- LeetCode 48. Rotate Image(旋转)
- leetcode 48. Rotate Image-矩阵旋转
- leetcode 48. Rotate Image(矩阵旋转)
- leetcode 48. Rotate Image 矩阵旋转
- [leetcode] 48. Rotate Image 解题报告
- Leetcode解题报告:48. Rotate Image
- 用 Hadoop 进行分布式并行编程
- LINUX 安装ftp详细步奏及用ftp在服务之间传输文件
- 数组--C语言中关于数组的小问题
- 2012年5月SAT香港真题解析
- Eclipse提示No java virtual machine
- leetCode 48.Rotate Image (旋转图像) 解题思路和方法
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoa
- 代理服务器
- 【To be continue】用过见过的芯片
- spring配置定时器的时间设置
- Latex 制作积分规则表格
- 2012年5月SAT香港真题解析
- cpu和内存之间——地址映射
- EXCEL 合并两列的内容