CA 14 - Valid Anagram
Solved
Easy
Topics
Given two strings s and t, return true if t is an of s, and false otherwise.
Example 1:
Input: s = "anagram", t = "nagaram"
Output: true
Example 2:
Input: s = "rat", t = "car"
Output: false
MY CODE:
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
a = []
b = []
for i in s:
a.append(i)
for j in t:
b.append(j)
a.sort()
b.sort()
return a == b
Comments
Post a Comment