Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa8bdd2

Browse files
committed
Time: 42 ms (86.65%) | Memory: 16.8 MB (84.85%) - LeetSync
1 parent 7b225a2 commit fa8bdd2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎242-valid-anagram/valid-anagram.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import itertools
2+
3+
class Solution:
4+
def isAnagram(self, s: str, t: str) -> bool:
5+
count_s={}
6+
for char in s:
7+
if char in count_s.keys():
8+
count_s[char] +=1
9+
else:
10+
count_s[char] = 1
11+
12+
13+
count_t={}
14+
for char in t:
15+
if char in count_t.keys():
16+
count_t[char] +=1
17+
else:
18+
count_t[char] = 1
19+
20+
if count_s == count_t:
21+
return True
22+
return False

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /