Skip to content

Commit 4d69389

Browse files
author
jiyseo
committed
[jiyseo] solve 2 problems
1 parent e61b656 commit 4d69389

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

climbing-stairs/jiyseo.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution(object):
2+
def fac(self, n) :
3+
fac = 1
4+
for i in range(1, n + 1) :
5+
fac *= i
6+
return fac
7+
8+
def climbStairs(self, n):
9+
res = 0
10+
for i in range(n // 2 + 1) :
11+
if i == 0 :
12+
res += 1
13+
else :
14+
cnt = n - i
15+
res += Solution().fac(cnt)/(Solution().fac(i) * Solution().fac(cnt - i))
16+
return res
17+

valid-anagram/jiyseo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution(object):
2+
def isAnagram(self, s, t):
3+
# 시간복잡도 = O(N * (N + M))
4+
if len(s) != len(t) :
5+
return False
6+
7+
for i in set(s) :
8+
if s.count(i) != t.count(i) :
9+
return False
10+
11+
return True
12+

0 commit comments

Comments
 (0)