[LeetCode]566. Reshape the Matrix
来源:互联网 发布:电脑软件开发学校 编辑:程序博客网 时间:2024/06/05 17:04
Solution如下
class Solution {public: vector<vector<int>> matrixReshape(vector<vector<int>> &nums, int r, int c) { if (nums.size() == 0 && r * c != 0) { return nums; } if (nums.size() * nums[0].size() != r * c) { return nums; } vector<vector<int>> ret(r, vector<int>()); cout << ret.size() << " " << ret[0].size() << endl; int index = 0; for (auto sub : nums) { for (auto i : sub) { ret[index / c].push_back(i); index++; if (index == r * c) return ret; } } return ret; }};
阅读全文
0 0
- leetcode 566. Reshape the Matrix
- LeetCode 566. Reshape the Matrix
- [LeetCode]566. Reshape the Matrix
- [leetcode]566. Reshape the Matrix
- LeetCode:566. Reshape the Matrix
- leetcode 566. Reshape the Matrix
- LeetCode | 566. Reshape the Matrix
- leetcode-566. Reshape the Matrix
- LeetCode 566.Reshape the Matrix
- LeetCode: 566. Reshape the Matrix
- LeetCode-566. Reshape the Matrix
- LeetCode * 566.Reshape the Matrix
- LeetCode: 566. Reshape the Matrix
- leetcode.566.Reshape the Matrix
- LeetCode 566. Reshape the Matrix
- [LeetCode] 566. Reshape the Matrix
- 【LeetCode】566. Reshape the Matrix
- [LeetCode]566. Reshape the Matrix
- Redis之 散列(hashes)
- 解决jsp用get方式通过a标签传值时的乱码问题
- 717. 1-bit and 2-bit Characters(第九周)
- 《Deep Learning》学习笔记一: BN的理解。
- 区域赛总结
- [LeetCode]566. Reshape the Matrix
- Elastic-Job-Lite 源码阅读 ---- 任务初始化
- Android移动开发-音量调节对话框的实现
- APP测试的认识
- html文件基本结构
- LVM(ext4+xfs的扩容和缩容)
- STM32GPIO口8种模式细致分析(类比51单片机)
- 字符串匹配_2
- 并发新特性—Lock锁和条件变量