Reshape the Matrix
来源:互联网 发布:郭德纲网络剧 编辑:程序博客网 时间:2024/06/14 14:55
class Solution(object): def matrixReshape(self, nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ if not nums or r*c != len(nums[0])*len(nums): return nums result = [[0 for _ in xrange(c)] for _ in xrange(r)] count = 0 for i in xrange(len(nums)): for j in xrange(len(nums[0])): result[count/c][count%c] = nums[i][j] count +=1 return result
阅读全文
0 0
- Reshape the Matrix
- 566. Reshape the Matrix
- 566.Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- LeetCode566. Reshape the Matrix
- 566. Reshape the Matrix
- LeetCode566. Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- 566. Reshape the Matrix
- Reshape the Matrix
- 566. Reshape the Matrix
- C++学习笔记
- 不能被继承的类
- HDOJ 4865 Peter's Hobby(概率dp, viterbi)
- 《Scrum实战》知易行难
- NDK编译——x86 支持
- Reshape the Matrix
- Python变量的三个特征获取方式
- Ubuntu16.04 x64服务器配置最新tcp拥塞控制算法bbr
- 大规模图像分类器的演化-Large-Scale Evolution of Image Classifiers-读后杂谈
- POJ 1031--Fence
- NDK编译——使用预构建库
- Ubuntu14.04安装网易云音乐
- NDK编译——C++ 库支持
- IOS点语法详解