본문 바로가기
python-algorithm

leetcode 242. Valid Anagram

by 무적김두칠 2023. 6. 23.

https://leetcode.com/problems/valid-anagram/description/?envType=study-plan-v2&envId=top-interview-150 

 

Valid Anagram - LeetCode

Can you solve this real interview question? Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using

leetcode.com

 

1
2
3
4
5
6
7
class Solution:
    def isAnagram(self, s: str, t: str-> bool:
        answer  =False
        s, t = sorted([i for i in s]), sorted([i for i in t])
        if s == t:
            answer =True
        return answer
cs
반응형

'python-algorithm' 카테고리의 다른 글

백준 1152 단어의 개수  (0) 2023.06.24
백준 1157 단어 공부  (0) 2023.06.24
leetcode 392. Is Subsequence  (0) 2023.06.19
leetcode 13. Roman to Integer  (1) 2023.06.19
leetcode 27. Remove Element  (0) 2023.06.19

댓글