Skip to content
Merged
Changes from 2 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
16 changes: 16 additions & 0 deletions valid-anagram/sun912.py
Copy link
Contributor

Choose a reason for hiding this comment

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

시공간 복잡도도 업데이트 해주시면 좋을것 같습니다 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

리뷰 감사합니다!! 복잡도 반영했습니다=)

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s) != len(t):
return False

count_s = {}
count_t = {}

for i in range(len(s)):
count_s[s[i]] = 1 + count_s.get(s[i], 0)
count_t[t[i]] = 1 + count_t.get(t[i], 0)

for c in count_t:
if count_t[c] != count_s.get(c, 0):
return False
return True