48. Rotate Image
来源:互联网 发布:c语言输出完全数 编辑:程序博客网 时间:2024/06/04 23:18
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?
Subscribe to see which companies asked this question
注意外圈的旋转次数为len-1
class Solution {public: void dorotate(vector<vector<int>>& matrix,int start,int len) { vector<int> temp; for(int i=0;i<len-1;++i) { int temp=matrix[start+i][start]; matrix[start+i][start]=matrix[start+len-1][start+i]; matrix[start+len-1][start+i]=matrix[start+len-1-i][start+len-1]; matrix[start+len-1-i][start+len-1]=matrix[start][start+len-1-i]; matrix[start][start+len-1-i]=temp; } } void rotate(vector<vector<int>>& matrix) { int len=matrix.size(); int p=0; for(int i=0;i<len;i+=2) { dorotate(matrix,p++,len-i); } return ; }};
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
- 字典树(+DFS)——Watto and Mechanism ( CodeForces 514C )
- UIView中空遮盖层,中间部分区域透明可视
- Hibernate各种主键生成策略与配置详解
- linux 高级字符设备驱动 ioctl操作介绍 例程分析实现
- FFmpeg+VS2013开发环境配置
- 48. Rotate Image
- 使用foreach输出枚举内容
- php字符串比较函数
- Struts2工作原理
- jquery和prototype.js的区别
- float double 避开科学计数法表示的手段
- 杭电OJ1005-斐波拉契相关Number Sequence
- 论python的类型推导
- Android 三种动画详解