diff --git a/climbing-stairs/do-heewan.py b/climbing-stairs/do-heewan.py new file mode 100644 index 000000000..b3311a6d3 --- /dev/null +++ b/climbing-stairs/do-heewan.py @@ -0,0 +1,11 @@ +class Solution: + def climbStairs(self, n: int) -> int: + dp = [0] * 46 + dp[1] = 1 + dp[2] = 2 + + for i in range(3, n+1): + dp[i] = dp[i-1] + dp[i-2] + + return dp[n] + diff --git a/product-of-array-except-self/do-heewan.py b/product-of-array-except-self/do-heewan.py new file mode 100644 index 000000000..3065f207e --- /dev/null +++ b/product-of-array-except-self/do-heewan.py @@ -0,0 +1,16 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + result = [] + + x = 1 + for element in nums: + result.append(x) + x *= element + + x = 1 + for i in range(len(nums)-1, -1, -1): + result[i] *= x + x *= nums[i] + + return result + diff --git a/valid-anagram/do-heewan.py b/valid-anagram/do-heewan.py new file mode 100644 index 000000000..b4c73fb00 --- /dev/null +++ b/valid-anagram/do-heewan.py @@ -0,0 +1,4 @@ +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + return sorted(s) == sorted(t) +