# 119. Pascal's Triangle II*

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?

class Solution(object):
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
result = [0]*(rowIndex+1)
result[0]= 1
for i in range(1,rowIndex+1):
for j in range(i,0,-1):
result[j] +=result[j-1]
return result

Note:

It is obvious that we should find the law of numbers in certain row of Pascal's Triangle.

According to materials online, the nth number in mth row is C(m,n-1).However, this method needs a lot of computation.

• 本文已收录于以下专栏：

## LeetCode119 Pascal's Triangle II

• zxwtry
• 2017年05月04日 22:23
• 222

## [LeetCode-119] Pascal's Triangle II（帕斯卡三角形第K行数据）

Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,...

## 119. Pascal's Triangle II

• yyg_wtf
• 2016年04月21日 10:43
• 200

## 118、119 pascal's triangle I、II---Array-LeetCode

118 pascal's triangle I---Array-LeetCode 找规律 a = b + c。 119 pascal's triangle II---Array-LeetCode ...

## <LeetCode OJ> 118 / 119 Pascal's Triangle(I / II)

118. Pascal's Triangle My Submissions Question Total Accepted: 73965 Total Submissions: 227957 D...

## LeetCode: Pascal's Triangle II [119]

【题目】 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retu...

## [119] Pascal's Triangle II

• camlot_
• 2016年07月19日 20:38
• 188

举报原因： 您举报文章：119. Pascal's Triangle II* 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)