diff --git a/climbing-stairs/Yiseull.py b/climbing-stairs/Yiseull.py new file mode 100644 index 0000000000..ae3e98cee2 --- /dev/null +++ b/climbing-stairs/Yiseull.py @@ -0,0 +1,11 @@ +class Solution: + def climbStairs(self, n: int) -> int: + if n == 1: return 1 + + dp = [0 for _ in range(n + 1)] + dp[0], dp[1] = 1, 1 + + for i in range(2, n + 1): + dp[i] = dp[i - 1] + dp[i - 2] + + return dp[n] diff --git a/product-of-array-except-self/Yiseull.py b/product-of-array-except-self/Yiseull.py new file mode 100644 index 0000000000..b30a955c49 --- /dev/null +++ b/product-of-array-except-self/Yiseull.py @@ -0,0 +1,15 @@ +class Solution: + def productExceptSelf(self, nums: List[int]) -> List[int]: + n = len(nums) + answer = [1] + + # answer[i] -> nums[i] 왼쪽 값들의 곱 + for i in range(1, n): + answer.append(answer[i - 1] * nums[i - 1]) + + tmp = 1 + for i in range(n - 1, -1, -1): + answer[i] *= tmp + tmp *= nums[i] + + return answer diff --git a/valid-anagram/Yiseull.py b/valid-anagram/Yiseull.py new file mode 100644 index 0000000000..b755e03fb8 --- /dev/null +++ b/valid-anagram/Yiseull.py @@ -0,0 +1,5 @@ +from collections import Counter + +class Solution: + def isAnagram(self, s: str, t: str) -> bool: + return Counter(s) == Counter(t)