¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Valid anagram

Suhas S Inglés 1 ficha

Fichas del conjunto (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

Información

Descripción
Fichas sobre Valid anagram, creado por Suhas S el 09/09/2019.
Creado por
Suhas S
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?