Leetcode 48. Rotate Image
来源:互联网 发布:opencv threshold源码 编辑:程序博客网 时间:2024/05/29 06:49
/** * Example, matrix[i][j] 0=<i<=3, 0=<j<=3 * * 1 2 3 4 * 5 6 7 8 * 9 10 11 12 * 13 14 15 16 * * Transpose the matrix by switching i and j to matrix[j][i], * * 1 5 9 13 * 2 6 10 14 * 3 7 11 15 * 4 8 12 16 * * Swap column 0 and i, 1 and i-1 ... to * * 13 9 5 1 * 14 10 6 2 * 15 11 7 3 * 16 12 8 4 * */public class Solution { public void rotate(int[][] matrix) { int tmp; int row = matrix.length; int col = matrix[0].length; // transpose the matrix, note that i<j (*) for (int i=0; i<row; i++) for (int j=0; j<i; j++) { tmp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = tmp; } // swap columns for (int i=0; i<col; i++) for (int j=0; j<row/2; j++) { tmp = matrix[i][j]; matrix[i][j] = matrix[i][row-1-j]; matrix[i][row-1-j] = tmp; } }}
0 0
- [LeetCode]48.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
- 48. Rotate Image LeetCode
- [LeetCode]48. 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
- LeetCode-48.Rotate Image
- [LeetCode] 48. Rotate Image
- LeetCode 48. Rotate Image
- oracle执行计划中NESTED LOOPS SEMI (即半嵌套循环)的解释
- Android 图片 剪切 大小无法控制,
- linux下搭建sdk,为什么我的工具这么少?
- 如何获取点击屏幕的位置
- uri与url的区别
- Leetcode 48. Rotate Image
- 2016年度学习总结
- NESTED LOOPS HASH JOIN
- 关于storyBoard里的间距的问题
- 需要做一个IP Carema 的安卓端!~求思路
- java,这个super在这里是什么用的
- 打包debug版本的apk会混淆吗
- Fragment跳到另一个Fragment
- android 仿qq电话的推送是怎么实现的,还请那位大牛,提供点参考资料或思路