Leetcode: Rotate Image
来源:互联网 发布:php模拟post提交数据 编辑:程序博客网 时间:2024/05/02 15:32
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?
void rotate(vector<vector<int> > &matrix) { // Note: The Solution object is instantiated only once.int n = matrix.size(); if(n<2)return;int loop=0;while(loop<(n+1)/2){int tmp = 0;for(int i = loop; i< n-1-loop;i++){tmp = matrix[loop][i];matrix[loop][i] = matrix[n-1-i][loop];matrix[n-1-i][loop] = matrix[n-1-loop][n-1-i];matrix[n-1-loop][n-1-i] = matrix[i][n-1-loop];matrix[i][n-1-loop] = tmp;}loop++;} }
- 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
- Just the Facts UVA568
- Eclipse、maven、m2eclipse安装
- 访问修饰控制符的作用域总结
- github 入门
- 快速排序及其JAVA实现
- Leetcode: Rotate Image
- C++解析JSON
- 大整数相乘
- java堆、栈、内存分析
- Leetcode_Populating Next Right Pointers in Each Node II
- 课本习题30页 2——6
- linux基础指令学习1
- 有序数组的合并
- java的移位运算和位运算