Skip to content

Commit 7309788

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c4f6fa5 commit 7309788

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

data_structures/arrays/pascals_triangle.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
In Pascal's triangle, each number is the sum of the two numbers directly above it.
1111
"""
1212

13+
1314
class Solution:
1415
def generate(self, num_rows: int) -> list[list[int]]:
1516
"""
@@ -34,14 +35,16 @@ def generate(self, num_rows: int) -> list[list[int]]:
3435
for i in range(num_rows):
3536
# Initialize the row with 1s
3637
row = [1] * (i + 1)
37-
38+
3839
# Compute inner elements by summing elements from the previous row
3940
for j in range(1, i):
40-
row[j] = ans[i-1][j-1] + ans[i-1][j]
41-
41+
row[j] = ans[i - 1][j - 1] + ans[i - 1][j]
42+
4243
ans.append(row)
4344
return ans
4445

46+
4547
if __name__ == "__main__":
4648
import doctest
49+
4750
doctest.testmod()

0 commit comments

Comments
 (0)