array1 [LeetCode] Pascal's Triangle 파이썬 (+Pascal's Triangle II) class Solution: # @return a list of lists of integers def generate(self, numRows): result = [] for i in range(numRows): result.append([]) for j in range(i + 1): if j in (0, i): # i==j(far right) or (j,0) (far left) result[i].append(1) else: result[i].append(result[i - 1][j - 1] + result[i - 1][j]) # left-leftup + left-up return result array 채우기 for j in range(i+1): fill row element Pascal's Tria.. 2021. 4. 1. 이전 1 다음