Array-leetcode 566 Reshape the Matrix
来源:互联网 发布:查询域名是否已备案 编辑:程序博客网 时间:2024/06/03 22:52
原题链接:Reshape the Matrix
题解:
public class Solution { public int[][] matrixReshape(int[][] nums, int r, int c) { /* Time Complexity:O(M*N) Space Complexity:O(M*N) */ int[][]res=new int[r][c]; int x=0,y=0; if(nums.length==0 || r*c!=nums[0].length*nums.length)return nums; for(int i=0;i<nums.length;i++) { for(int j=0;j<nums[0].length;j++){ res[x][y]=nums[i][j]; y++; if(y==c){ x++; y=0; } } } return res; }}
阅读全文
0 0
- Array-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
- Reshape the Matrix(leetcode)
- leetCode-Reshape the Matrix
- leetcode 数组array之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之Reshape the Matrix
- LeetCode:566. Reshape the Matrix
- leetcode 566. Reshape the Matrix
- LeetCode | 566. Reshape the Matrix
- (考试)2017年大一下学期C++期末考试题目五
- Levenshtein编辑距离
- hbase 源代码解析(3) 的createTable 服务端解析第二部分
- 爬取糗事百科的段子Demo
- Python中defaultdict与lambda表达式小结
- Array-leetcode 566 Reshape the Matrix
- CSS随笔2
- ceph dd 测试读写
- 对日志数据中的上下行流量信息汇总---分区统计
- 解决,未加载kernelbase.pdb,问题
- 欢迎使用CSDN-markdown编辑器
- Pycharm自动安装第三方的python库
- 【CodeVS 1007】级数求和
- Windows下Qt调用C++命令行程序——参数传递、字符编码转换