[leetcode刷题系列]Rotate Image
来源:互联网 发布:nagle算法作用 编辑:程序博客网 时间:2024/05/21 15:06
算是模拟题把, 至于in-place,简单想下就好了, 规律还是很容易发现的。只是写的时候下标要想清楚,别写错。
class Solution { void change(int &a, int &b, int &c, int &d){ int tmp = d; d = c; c = b; b = a; a = tmp; }public: void rotate(vector<vector<int> > &matrix) { // Start typing your C/C++ solution below // DO NOT write int main() function int n = matrix.size(); for(int i = 0;i < n / 2; ++ i){ for(int j = i; j + i + 1 < n; ++ j) change(matrix[i][j], matrix[j][n - 1 -i], matrix[n - 1 - i][n - 1 -j], matrix[n - 1 - j][i]); } }};
- [leetcode刷题系列]Rotate Image
- leetcode刷题系列C++-rotate image
- [leetcode刷题系列]Rotate List
- leetcode 刷题之路 34 Rotate Image
- 算法系列--Rotate Image
- LeetCode算法题之Rotate Image
- LeetCode 第 48 题(Rotate Image)
- 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
- tonardo做web服务器播放大视频内存泄露问题的解决
- POJ 2318 / 2389 几何入门题
- webRTC 网关技术点分析
- 用HTML5绘制骰子
- oracle 11g rac 安装报错 CRS-2500
- [leetcode刷题系列]Rotate Image
- 在Eclipse中跑b3log的设置
- Problem 11:Largest product in a grid
- 关于静态变量“赋值无效问题”的探讨结果
- Google-ProtoBuf数据编码
- 【原来如此】为什么很多应用都安装在/usr/local目录下?
- 菜鸟学Java(八)——dom4j详解之读取XML文件
- HDU--杭电--1240--Asteroids!--广搜--贴个水题别群殴我
- springside 备注