---
# System prepended metadata

title: 'Pascal''s Triangle <img src="https://img.shields.io/badge/-easy-brightgreen">'
tags: [data_structure_python]

---

---
tags: data_structure_python
---

# Pascal's Triangle <img src="https://img.shields.io/badge/-easy-brightgreen">

Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.

<ins>**Example:**</ins>

```
Input: 5
Output:
[
     [1],
    [1,1],
   [1,2,1],
  [1,3,3,1],
 [1,4,6,4,1]
]
```

## Solution

```python=
class Solution:
    def generate(self, numRows: int) -> List[List[int]]:
        pascalTriangle, tmp = [], [1]

        for i in range(1, numRows+1):
            row = [1]*i
            for j in range(0, len(tmp)-1):
                row[j+1] = tmp[j] + tmp[j+1]

            pascalTriangle.append(row)
            tmp = row

        return pascalTriangle
```
