[LeetCode][Python3] 118. Pascal's Triangle
                2018. 10. 17. 01:25 |
                
                    프로그래밍/LeetCode
                
            
            
            
        Problem :
https://leetcode.com/problems/pascals-triangle/description/
My Solution :
class Solution:
    def generate(self, numRows):
        """
        :type numRows: int
        :rtype: List[List[int]]
        """
        ans = []
        for i in range(1, numRows+1):
            row = [1]
            for j in range(1, i):
                row.append(sum(ans[i-2][j-1:j+1]))
            ans.append(row)
        return ans
'프로그래밍 > LeetCode' 카테고리의 다른 글
| [LeetCode][Python3] 172. Factorial Trailing Zeroes (0) | 2018.11.03 | 
|---|---|
| [LeetCode][Python3] 171. Excel Sheet Column Number (0) | 2018.11.03 | 
| [LeetCode][Python3] 122. Best Time to Buy and Sell Stock II (0) | 2018.11.03 | 
| [LeetCode][Python3] 88. Merge Sorted Array (0) | 2018.11.03 | 
| [LeetCode][Python3] 125. Valid Palindrome (0) | 2018.10.17 | 
| [LeetCode][Python3] 66. Plus One (0) | 2018.10.15 | 
| [LeetCode][Python3] 543. Diameter of Binary Tree (0) | 2018.10.09 | 
| [LeetCode][Python3] 617. Merge Two Binary Trees (0) | 2018.10.08 | 
최근에 달린 댓글 최근에 달린 댓글