Skip to content

Commit 838765d

Browse files
committed
adding algo
1 parent bd4c99f commit 838765d

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def climbStairs(self, n: int) -> int:
3+
4+
a, b = 1, 1
5+
6+
for i in range(n):
7+
a, b = b, a + b
8+
9+
return a
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function climbStairs(n: number): number {
2+
let a = 1;
3+
let b = 1;
4+
5+
for (let i = 0; i < n; i++) {
6+
const temp = b;
7+
b = a + b;
8+
a = temp;
9+
}
10+
11+
return a;
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_22\
3+
.ex_132_climbing_stairs import Solution
4+
5+
class ClimbingStairsTestCase(unittest.TestCase):
6+
7+
def test_climbing_stairs(self):
8+
solution = Solution()
9+
output = solution.climbStairs(n=3)
10+
target = 3
11+
self.assertEqual(output, target)

0 commit comments

Comments
 (0)