Description
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
My solution
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
new_t = t
for i in s:
t= t.replace(i, "", 1)
for j in new_t:
s = s.replace(j, "", 1)
return True if (t == "") and (s == "") else False
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
return sorted(list(s)) == sorted(list(t))
문제 출처 : https://leetcode.com/problems/valid-anagram/submissions/
'Algorithm > Daily Coding Tests Challenge' 카테고리의 다른 글
[Leetcode] Hard : Median of Two Sorted Array (0) | 2021.10.09 |
---|---|
[Leetcode] Medium : Search in Rotated Sorted Array (0) | 2021.10.09 |
[프로그래머스] level2. 가장 큰 수 (0) | 2021.09.15 |
[프로그래머스] level2. H-Index (0) | 2021.09.13 |
[Leetcode] Easy: Same Tree (0) | 2021.09.09 |