leetcode48. Rotate Image
来源:互联网 发布:淘宝客机器人手机版 编辑:程序博客网 时间:2024/05/16 14:05
leetcode48. Rotate Image
class Solution {public: void rotate(vector<vector<int>>& matrix) { int centralCircle = matrix.size() / 2 ; for(int i=0;i<centralCircle;i++){ rotateCircle(matrix,i); } } void rotateCircle(vector<vector<int>>& matrix,int circle) { if(matrix.size()<=1) return ; int xStart = circle; int yStart = circle; int xEnd = matrix.size() - 1 - circle; int yEnd = matrix.size() - 1 - circle; int temp = matrix[xStart][yStart]; //rotate corner int maxIndex = xEnd - xStart; //rotate the other for(int y=0;y<maxIndex;y++){ temp = matrix[xStart][yStart+y]; matrix[xStart][yStart+y] = matrix[xEnd - y][yStart]; matrix[xEnd - y][yStart] = matrix[xEnd][yEnd - y]; matrix[xEnd][yEnd - y] = matrix[xStart+y][yEnd]; matrix[xStart+y][yEnd] = temp; } }};
阅读全文
0 0
- Leetcode48 Rotate Image
- leetcode48~Rotate Image
- LeetCode48. Rotate Image
- LeetCode48. Rotate Image题解
- leetcode48. Rotate Image
- Leetcode48. Rotate Image
- Leetcode48 Rotate Image
- leetcode48. Rotate Image
- LeetCode48——Rotate Image
- LeetCode48/189 Rotate Image/Rotate Array
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- 章节10课时74Bash变量-预定义变量
- video + webapi (一)
- linux系统中Virtualbox启用USB设备支持的方法
- SSM环境搭建——简单实现SSM整合
- R基础绘图
- leetcode48. Rotate Image
- 程序员维护老产品,闲的焦虑,怎么办
- 敏捷之旅西安站现场活动,6大主题
- 滚动轴承故障特征频率的计算
- 编译RT-tests进行Linux实时性测试
- docker网络配置
- Ubuntu下Titan 环境搭建
- Kaggle搭积木式刷分大法: LB 0.11666(排名前15%)
- The Accomodation of Students