Pascal's Triangle question very simple, time complexity is O (N), the spatial complexity is O (1)
class Solution: def generate(self, numRows: int) -> List[List[int]]: if numRows == 0: return [] result = [[1]] for row in range(1,numRows): new_row = [1] for col in range(len(result[row - 1]) - 1): new_row.append(result[row - 1][col] + result[row - 1][col + 1]) new_row.append(1) result.append(new_row) return result