leetcode_c++:Rotate Image(048)
来源:互联网 发布:大数据时代如何赚钱 编辑:程序博客网 时间:2024/05/18 00:53
题目
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?
算法
复杂度:O(n^2)
- 对角线swap
- 行反转
class Solution {public: void rotate(vector<vector<int> >& matrix) { int n=matrix.size(); for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) swap(matrix[i][j],matrix[j][i]); for(int i=0;i<n;i++) reverse(matrix[i].begin(),matrix[i].end()); }};
0 0
- leetcode_c++:Rotate Image(048)
- LeetCode 048 Rotate Image
- LeetCode(048) Rotate Image
- LeetCode 048 Rotate Image
- 048 - Rotate Image
- leetcode 048 Rotate Image
- [LeetCode]048-Rotate Image
- LeetCode 048 Rotate Image
- LeetCode(48)Rotate Image
- leetcode_c++:链表:Rotate List(061)
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Uva10954——Add All
- TX游戏多开分析
- leetcode.316. Remove Duplicate Letters
- android中的各类权限
- Android 学习笔记(二)
- leetcode_c++:Rotate Image(048)
- 【蓝桥杯】 骰子迷题
- java 链表数据结构实现
- Android面试必考基础题
- JAVA中关于String类型的创建和字符串常量池的问题
- CodeForces 451E Devu and Flowers(容斥原理+组合数学+状态压缩)
- 如何卸载Oracle 10g
- 谈谈这几年干的一些事情和认识的一些人把。
- c++作业6-项目2,3