From ecb66b0dae1b7a599217d1fc91fe36131c99a3a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 27 Mar 2025 04:34:37 -0600 Subject: [PATCH] adding climbing stairs algo --- .../top_150_questions_round_14/climbing_stairs.py | 12 ++++++++++++ .../test_climbing_stairs_round_14.py | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_14/climbing_stairs.py create mode 100644 tests/test_150_questions_round_14/test_climbing_stairs_round_14.py diff --git a/src/my_project/interviews/top_150_questions_round_14/climbing_stairs.py b/src/my_project/interviews/top_150_questions_round_14/climbing_stairs.py new file mode 100644 index 00000000..59fe778f --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_14/climbing_stairs.py @@ -0,0 +1,12 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def climbStairs(self, n: int) -> int: + + a, b = 1, 1 + + for i in range(n): + a, b = b, a + b + + return a diff --git a/tests/test_150_questions_round_14/test_climbing_stairs_round_14.py b/tests/test_150_questions_round_14/test_climbing_stairs_round_14.py new file mode 100644 index 00000000..d4dd7b74 --- /dev/null +++ b/tests/test_150_questions_round_14/test_climbing_stairs_round_14.py @@ -0,0 +1,11 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_14\ +.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