CA 14 - Valid Anagram

Easy
Topics
premium lock iconCompanies

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

Popular posts from this blog

CA 22 - Reverse a Linked List