### 119.  Pascal's Triangle II

题目： 
<https://leetcode.com/problems/pascals-triangle-ii/>

难度 : Easy



思路：

高中数学



这种算法会超时|||

```
class Solution(object):
    def getRow(self, rowIndex):
        """
        :type rowIndex: int
        :rtype: List[int]
        """
        def combNum(n,k):
        	if k == 0 or k == n :
        		return 1
        	return combNum(n-1,k-1) + combNum(n-1,k) 
        res = []
        for i in range(rowIndex + 1):
        	res.append(combNum(rowIndex,i))

        return res
```



用118改的，AC代码



```
class Solution(object):
    def getRow(self, rowIndex):
        """
        :type rowIndex: int
        :rtype: List[int]
        """
        res = [[1],[1,1]]
        if rowIndex < 2:
            return res[rowIndex]
        for i in range(3, rowIndex+2):
            tmp = [1] * i
            for j in range(1,i-1):
                tmp[j] = res[i-2][j-1] + res[i-2][j]
            res.append(tmp)
        return res[-1]
```

