48. Rotate Image
来源:互联网 发布:淘宝关键词检索规律 编辑:程序博客网 时间:2024/06/06 20:14
这是我第一次一遍AC,这题看过一次解题思路,先左右对称,在斜对称
public class Solution { public void rotate(int[][] matrix) { int n = matrix.length; for(int j=0;j<n;j++)//偶和奇数都一样的 for(int i=0;i<n/2;i++){ swap(matrix,j,i,j,n-i-1); } for(int j=0;j<n;j++) for(int i=0;i<n-j;i++){ swap(matrix,j,i,n-1-i,n-1-j); } } private void swap(int[][]matrix,int x1,int y1,int x2,int y2){ int t = matrix[x1][y1]; matrix[x1][y1] = matrix[x2][y2]; matrix[x2][y2] = t; }}
0 0
- [LeetCode]48.Rotate Image
- LeetCode 48. Rotate Image
- LeetCode 48.Rotate Image
- LeetCode --- 48. Rotate Image
- [Leetcode] 48. Rotate Image
- 48. Rotate Image
- 48. Rotate Image
- 48. Rotate Image
- 48. Rotate Image
- [leetcode] 48. Rotate Image
- Leetcode 48. Rotate Image
- 48. Rotate Image LeetCode
- [LeetCode]48. Rotate Image
- 48. Rotate Image
- 48. Rotate Image
- leetcode 48. Rotate Image
- Leetcode 48. Rotate Image
- LeetCode 48. Rotate Image
- C++ 虚函数表及调用规范详解
- 解压版tomcat启动闪退解决办法,需要配置tomcat的环境变量!
- 强力推荐:Atom入坑必备插件
- 安卓高级1 -----Xutil3 和Picasso使用
- IOS9 Xcode7 下的布局神器 Stack Views
- 48. Rotate Image
- LINUX KERNEL启动参数
- Android工具类整理
- Linux下利用jTessBoxEditor工具进行Tesseract3.02.02样本训练
- 台大林轩田《机器学习基石》学习笔记7:线性模型三(Multiclass Prediction)
- VC 刷新桌面图标和任务栏图标
- 关于学习编程的心得
- C++的四种强制类型转换
- epoll在LT和ET模式下的读写方式