119. Pascal's Triangle II (python)
来源:互联网 发布:java语言程序设计下载 编辑:程序博客网 时间:2024/05/16 19:43
Given an index k, return the kth row of the Pascal’s triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k) extra space?
题意:返回杨辉三角的k行
思路:和118. Pascal’s Triangle,只是此处行数从0开始,k=3对应第四行
Runtime: 55 ms
class Solution(object): def getRow(self, rowIndex): tem=[0,1] for i in range(rowIndex+1): rowlist=[] for j in range(len(tem)-1): rowlist.append(tem[j]+tem[j+1]) tem=rowlist[:] tem.insert(0,0) tem.append(0) return rowlist
0 0
- 119. Pascal's triangle II Leetcode Python
- 119. Pascal's Triangle II [easy] (Python)
- 119. Pascal's Triangle II (python)
- 【Leetcode】【python】Pascal's Triangle, Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 119. Pascal's Triangle II
- 关于Android ANR的思考
- 使用TextView实现ImageView效果
- LeetCode学习篇十一——Range Sum Query - Immutable
- MySQL——数据库语言+语法
- HPC —— 高性能计算
- 119. Pascal's Triangle II (python)
- node.js利用javascript中构造函数继承,实现模块调用
- android快速实现毛玻璃效果
- 121. Best Time to Buy and Sell Stock (python)
- 书本ISBN号码校验
- 省市联动(struts2+ajax+非数据库)
- c++模版-学习记录
- ios JSPatch热更新技术详解
- 二分查找