Rotate Image -- leetcode
来源:互联网 发布:《网络黑白》txt下载 编辑:程序博客网 时间:2024/06/11 11:25
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) { const int n = matrix.size(); for (int i=0; i<n/2; i++) { for (int j=i; j<n-i-1; j++) { const int bak = 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] = bak; } } }};
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
- js 根据 useragent 判断访问网页的 设备 和 浏览器
- IOS开发系列--IOS程序开发概览
- 【学习笔记】JAVA之使用dom4j对xml文件解析
- Use a layout_height of 0dp instead of match_parent for better performance问题说明
- C++ list用法汇总
- Rotate Image -- leetcode
- Linux下的绘图(流程图、UML、mindmap)工具
- 找工作总结
- 如何在eclipse中添加android ADT
- 异步任务的总结
- IIS7.5 批量开设站点
- MyEclipse使用教程:MyEclipse用前必看
- Apple 企业开发者账号&邓白氏码申请记录
- online_judge_1470