leetcode 566 Reshape the Matrix
2017-10-17 21:20
405 查看
class Solution { public int[][] matrixReshape(int[][] nums, int r, int c) { int x=nums.length; int y=nums[0].length; if(x*y!=r*c) return nums; int[][] ans=new int[r][c]; for(int i=0;i<r*c;i++) ans[i/c][i%c]=nums[i/y][i%y]; return ans; } }
相关文章推荐
- 【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-E
- LeetCode566——Reshape the Matrix
- leetcode 数组array之566. Reshape the Matrix
- [Leetcode] 566. Reshape the Matrix 解题报告
- LeetCode-566:Reshape the Matrix (矩阵整型)-- easy
- 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 (C++) O(n)
- LeetCode 566 Reshape the Matrix 重置矩阵
- LeetCode 566. Reshape the Matrix (Easy)
- [LeetCode]566. Reshape the Matrix(重塑矩阵)
- Array-leetcode 566 Reshape the Matrix