GoConqr has a new look! Let us know what you think.

Flashcards

Valid anagram

Suhas S English 1 card

Cards in this deck (1)

  1. 1Valid anagramclass Solution:
    def isAnagram(self, s: str, t: str) -> bool:
    # sortedS = ''.join(sorted(s))
    # sortedT = ''.join(sorted(t))
    # if sortedS == sortedT:
    # return True
    # return False
    # dict_count = {}
    # for i in s:
    # if i in dict_count:
    # dict_count[i] += 1
    # else:
    # dict_count[i] = 1
    # for i in t:
    # if i in dict_count:
    # dict_count[i] = dict_count[i] - 1
    # if dict_count[i] < 0:
    # return False
    # else:
    # return False
    # for key,value in dict_count.items():
    # if value != 0:
    # return False
    # return True
    if len(s) != len(t):
    return False
    if set(s) != set(t):
    return False
    for i in set(s):
    if s.count(i) != t.count(i):
    return False
    return True

Information

Description
Flashcards on Valid anagram, created by Suhas S on 09/09/2019.
Created by
Suhas S
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?