Rotate Image
来源:互联网 发布:如何利用知乎赚钱 编辑:程序博客网 时间:2024/06/04 00:47
-----QUESTION-----
You are given an
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
-----SOLUTION-----
class Solution {public: void rotate(vector<vector<int> > &matrix) { int temp; for(int i = 0; i < matrix.size()/2; i++) { for(int j = i; j < matrix[0].size()-i-1; j++) { temp = matrix[i][j]; matrix[i][j] = matrix[matrix[0].size()-1-j][i]; matrix[matrix[0].size()-1-j][i] = matrix[matrix.size()-1-i][matrix.size()-1-j]; matrix[matrix.size()-1-i][matrix.size()-1-j] = matrix[j][matrix.size()-1-i]; matrix[j][matrix.size()-1-i] = temp; } } }};
0 0
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- SQL:如何为SQL SERVER2008 启用远程连接(Remote Connect)
- 《炉石传说》架构设计赏析(2):Scene管理
- pomelo配置logger时日志无法输出到日志文件的问题解决方案
- userdel:无法打开密码文件
- ajaxFileUpload上传文件时IE浏览器弹出下载提示问题处理
- Rotate Image
- 沈博阳:互联网创业者在中国生存必须有坚韧素质
- c++ 全局变量
- 程序收藏
- Why programming is so difficult. 感同身受的文章
- IT忍者神龟之Struts2-Json-Plugin 的使用(翻译自官方文档)
- android.os.NetworkOnMainThreadException
- CSFB(电路域回落)
- Permutations