Skip to content

Commit 8018a3d

Browse files
Update algorithms/dynamic_programming/climb_stairs/__init__.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent c80e003 commit 8018a3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

algorithms/dynamic_programming/climb_stairs/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def climb_stairs(n: int) -> int:
1414

1515

1616
def climb_stairs_dp_bottom_up(n: int) -> int:
17-
if n == 1:
17+
if n < 0:
18+
return 0
19+
if n <= 1:
1820
return 1
1921

2022
dp = [0] * (n + 1)

0 commit comments

Comments
 (0)