<!-- <b> --> # <span style="color: green">[Easy]</span> 118. Pascal's Triangle ## Problem Summary Given a number of height, return the Pascal's Triangle the form of list. ## šŸ’” Approach The easy approach is to iterate for all layer, assigned them to be the sum of two elements from upper layer. ## </> Code ```python class Solution: def generate(self, numRows: int) -> List[List[int]]: tri = [[1]] for i in range(1, numRows): tmp = [1] for j in range(1, i): tmp.append(tri[i-1][j] + tri[i-1][j-1]) tmp.append(1) tri.append(tmp) return tri ``` ## šŸ•’ Runtime Time: `0ms` | `Beats 100%` Memory: `17.86MB` | `Beats 37.13%` ## šŸ“ˆ Complexity <b>Assume that: </b> - `n` is the given number <b>The overall complexity:</b> - Time Complexity: `O(n²)` - Space Complexity: `O(n²)`