diff --git a/src/my_project/interviews/top_150_questions_round_22/ex_132_climbing_stairs.py b/src/my_project/interviews/top_150_questions_round_22/ex_132_climbing_stairs.py new file mode 100644 index 00000000..ac720018 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_22/ex_132_climbing_stairs.py @@ -0,0 +1,9 @@ +class Solution: + def climbStairs(self, n: int) -> int: + + a, b = 1, 1 + + for i in range(n): + a, b = b, a + b + + return a \ No newline at end of file diff --git a/src/my_project/interviews_typescript/top_150_questions_round_1/ex_132_climbing_stairs.ts b/src/my_project/interviews_typescript/top_150_questions_round_1/ex_132_climbing_stairs.ts new file mode 100644 index 00000000..b8fc0e8c --- /dev/null +++ b/src/my_project/interviews_typescript/top_150_questions_round_1/ex_132_climbing_stairs.ts @@ -0,0 +1,12 @@ +function climbStairs(n: number): number { + let a = 1; + let b = 1; + + for (let i = 0; i < n; i++) { + const temp = b; + b = a + b; + a = temp; + } + + return a; +} \ No newline at end of file diff --git a/tests/test_150_questions_round_22/test_132_climbing_stairs_round_22.py b/tests/test_150_questions_round_22/test_132_climbing_stairs_round_22.py new file mode 100644 index 00000000..3bd7999d --- /dev/null +++ b/tests/test_150_questions_round_22/test_132_climbing_stairs_round_22.py @@ -0,0 +1,11 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_22\ +.ex_132_climbing_stairs import Solution + +class ClimbingStairsTestCase(unittest.TestCase): + + def test_climbing_stairs(self): + solution = Solution() + output = solution.climbStairs(n=3) + target = 3 + self.assertEqual(output, target) \ No newline at end of file