Rotate Image
来源:互联网 发布:法国娇兰 淘宝 编辑:程序博客网 时间:2024/06/15 17:20
这道题一开始看觉得很简单,就是矩阵的旋转。
但是不能用多余的空间,那么选哪些量来做旋转就需要思考了
class Solution {public: void rotate(vector<vector<int> > &matrix) { int n = matrix.size(); for(int i = 0;i<n/2;i++) { for(int j =i;j<n-i-1;j++) { int temp = matrix[i][j]; matrix[i][j] = matrix[n-1-j][i]; matrix[n-1-j][i] = matrix[n-1-i][n-1-j]; matrix[n-1-i][n-1-j] = matrix[j][n-1-i]; matrix[j][n-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
- Tomcat8安装与配置
- 异常处理
- 信息安全之ssh(Secure Shell)
- 线程范围内共享变量的概念与作用
- 打补丁常见错误patch: **** malformed patch at line
- Rotate Image
- ROWNUM的使用
- android通讯录 添加联系人
- 猿题库唐巧:iOS应用安全开发你不知道的那些事儿
- [Bzoj1911][Apio2010]特别行动队
- 在构造函数中使用new时应注意的事项
- 控制浏览器定时自动刷新
- 哪位大神能帮帮我编写下双向链表这个程序
- 【Bzoj1610】[Usaco2008 Feb]Line连线游戏