4.34 leetcode -34 rotate-image
来源:互联网 发布:项目管理 源码 编辑:程序博客网 时间:2024/05/17 21:59
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(); vector<vector <int> > matrixtmp(n ,vector<int>(n)); for(int i = 0;i < n;i++) { for(int j = 0;j < n;j ++) { matrixtmp[j][n-i-1] = matrix[i][j]; } } for(int i = 0;i < n;i++) { for(int j = 0;j < n;j ++) { matrix[i][j] = matrixtmp[i][j]; } } }};
阅读全文
0 0
- 4.34 leetcode -34 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
- leetcode之Rotate Image
- LeetCode - Rotate Image
- Leetcode: Rotate Image
- LeetCode:Rotate Image
- Leetcode: Rotate Image
- Leetcode Rotate Image
- 同一张表中将去重的数量展示
- C#中标准Dispose模式的实现
- echarts 地图数据补充 自定义区域
- c语言的一些技巧
- 循环链表
- 4.34 leetcode -34 rotate-image
- better-scroll滚动不了的问题
- 2017第十二届中国(山西)建筑装饰材料博览会会刊(参展商名录)
- 快速查找素数
- Hashcode的作用。
- maven scm插件 配置git
- Hadoop2.7.4 MapReduce开发部署步骤
- Posix多线程编程学习笔记
- 引用类型赋值为null与加速垃圾回收