【LeetCode】Rotate Image
来源:互联网 发布:诺基亚6600s软件 编辑:程序博客网 时间:2024/05/18 11:47
题目描述:
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?
代码:
class Solution {public:void rotate(vector<vector<int> > &matrix) {//先左右翻转int N = matrix.size();for (int i = 0; i < N;i++)for (int j = 0; j < N / 2; j++)swap(matrix[i][j], matrix[i][N - 1 - j]);//再以右斜线为轴翻转for (int i = 0; i < N;i++)for (int j = 0; j < N - 1 - i; j++)swap(matrix[i][j], matrix[N - 1 - j][N - 1 - i]);}};
0 0
- LeetCode: Rotate Image
- [Leetcode] Rotate Image
- LeetCode : Rotate Image
- [LeetCode] Rotate Image
- leetcode 67: Rotate Image
- [leetcode] Rotate Image
- [Leetcode] Rotate Image
- [LeetCode]Rotate Image
- LeetCode-Rotate Image
- [leetcode] Rotate Image
- LeetCode - Rotate Image
- leetcode之Rotate Image
- LeetCode - Rotate Image
- Leetcode: Rotate Image
- LeetCode:Rotate Image
- Leetcode: Rotate Image
- Leetcode Rotate Image
- leetcode Rotate Image
- 字符串的不可变性
- 在HREL6.5下安装Zabbix 2.2.3
- JS中使用正则表达式
- python爬虫之采集360搜索的联想词
- css开发
- 【LeetCode】Rotate Image
- Android 中的dp,px深度解析
- c# winform 路径选择和文件读写
- uip移植telnetd并添加自定义命令
- Ubuntu下离线安装软件包
- oracle的卸载
- 回文数另一解
- zabbix2.2.3中乱码的解决方法
- 20140613_JavaWeb学习之开发环境配置篇