leetcode 48. Rotate Image-矩阵旋转
来源:互联网 发布:windows画图软件下载 编辑:程序博客网 时间:2024/05/22 02:20
原题链接:48. Rotate Image
【思路-Java】
矩阵的顺时针90°旋转,关键是找到坐标关系。本题中 n 的值提前减1了,所以在下面的运算中就没有减1了。
public class Solution { public void rotate(int[][] matrix) { for(int i=0, temp=0, n=matrix.length-1; i<=n/2; i++) { for(int j=i; j<n-i; j++) { temp = matrix[j][n-i]; matrix[j][n-i] = matrix[i][j]; matrix[i][j] = matrix[n-j][i]; matrix[n-j][i] = matrix[n-i][n-j]; matrix[n-i][n-j] = temp; } } }}20 / 20 test cases passed. Runtime: 0 ms Your runtime beats 25.77% of javasubmissions.
2 0
- leetcode 48. Rotate Image-矩阵旋转
- leetcode 48. Rotate Image(矩阵旋转)
- leetcode 48. Rotate Image 矩阵旋转
- Rotate Image 旋转矩阵 @LeetCode
- LeetCode-----48. Rotate Image(二维矩阵旋转90度)
- LeetCode Rotate Image(矩阵的旋转)
- leetcode-48 Rotate Image 旋转矩阵
- LeetCode-48-Rotate Image 矩阵旋转90
- 【旋转矩阵】Rotate Image
- LeetCode 48. Rotate Image(旋转)
- leetcode:Rotate Image (旋转矩阵)【面试算法题】
- 【LeetCode】48 Rotate Image && 【九度】题目1164:旋转矩阵
- 将矩阵顺时针旋转90度 leetCode:Rotate Image
- [leetcode 48] Rotate Image--------矩阵旋转90度
- leetcode rotate-image(90°旋转矩阵)
- LeetCode Rotate Image旋转图像
- Leetcode:Rotate Image 旋转图片
- [LeetCode] Rotate Image 旋转图像
- C++队列和优先权队列的使用---应用:带时限作业排序
- linux(ubuntu) 下安装nodejs
- 动态规划 金矿模型 01背包问题
- 好用的工具合集
- 最新android工程目录下armeabi-v7a,armeabi的具体含义,有什么区别
- leetcode 48. Rotate Image-矩阵旋转
- Retrofit A type-safe HTTP client for Android and Java
- 触发器学习笔记(:new,:old用法)
- JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not
- 第14周项目1-排序函数模板
- oracle 正则表达式
- 查看签名apk调试日志工具
- HDU Hdu Girls' Day
- Top 10 Open Dataset Resources on Github