Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions valid-anagram/jiunshinn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# time complexity O(n)
# space complexity O(n)


class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False

counter_s = {}
counter_t = {}

for char in s:
counter_s[char] = counter_s.get(char, 0) + 1

for char in t:
counter_t[char] = counter_t.get(char, 0) + 1

if counter_s == counter_t:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return counter_s == counter_t로 줄일 수 있습니다

return True
else:
return False