We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a8e5ba commit 3f4a8e2Copy full SHA for 3f4a8e2
valid-anagram/mandel-17.py
@@ -1,15 +1,14 @@
1
+import collections
2
+
3
class Solution:
- def isAnagram(self, s: str, t: str) -> bool:
- def count_char(target_str):
4
- dict_char = {}
5
- for c in target_str:
6
- dict_char[c] = dict_char.get(c, 0) + 1
7
- return dict_char
+ num_dict = collections.defaultdict(int)
8
9
- dict_s = count_char(s)
10
- dict_t = count_char(t)
+ def climbStairs(self, n: int) -> int:
+ if n <= 2:
+ return n
11
12
- if dict_s == dict_t:
13
- return True
14
- return False
+ if self.num_dict[n]:
+ return self.num_dict[n]
15
+ self.num_dict[n] = self.climbStairs(n-1) + self.climbStairs(n-2)
0 commit comments