[LeetCode] Valid Anagram

yoonene·2023년 2월 10일
0

알고리즘

목록 보기
52/62

1 트

class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        return sorted(s) == sorted(t)

2 트

from collections import Counter
class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        return Counter(s) == Counter(t)

sorted보다 Counter로 한 게 더 빨랐다.
유의미한건지는 일단 내일 알아볼 것

profile
NLP Researcher / Information Retrieval / Search

0개의 댓글