comitando isAnagram

This commit is contained in:
Moises Antonio Hernandez Ferrer Gonçalves 2022-11-02 10:44:53 -03:00
parent b8e38b15c8
commit 4b953728a9

View File

@ -1,4 +1,23 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
}
isAnagram["roma", "amor"]
isAnagram["Buckethead" ,"Deathcubek"]
isAnagram["Twoo" ,"Woot"]
isAnagram["dumble" ,"bumble"]
isAnagram["ound" ,"round"]
isAnagram["apple" ,"pale"]
}
if ( s1.length() != s2.length() ) {
return false;
}
//tranfroma em arrays para poder ordenar
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
//ordena para garantir a comparação simplificada
Arrays.sort(c1);
Arrays.sort(c2);
//novas arrays ordenados
String sc1 = new String(c1);
String sc2 = new String(c2);
return sc1.equals(sc2);