fix: optimizacão de isAnagram e maxValue #2

Merged
JoseGregorioMataRodriguez merged 1 commits from feature-algorithms into master 2022-10-29 20:08:15 +00:00
2 changed files with 27 additions and 24 deletions
Showing only changes of commit 10ef9194b8 - Show all commits

View File

@ -1,13 +1,13 @@
export function maxValue(values) {
// implementar logica aqui
let numeromaior = 0;
if (values[0] < numeromaior)
numeromaior = values[0];
let i = 0;
for (i = 0; i < values.length; i++){
if (numeromaior < values[i]){
numeromaior = values[i];
}
}
return numeromaior;
if (values[0] < numeromaior)
numeromaior = values[0];
let i = 0;
for (i = 0; i < values.length; i++){
if (numeromaior < values[i]){
numeromaior = values[i];
}
}
return numeromaior;
}

View File

@ -1,22 +1,25 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if ((!word1) || (!word2))
return false;
if (word1 != word2){
if (word1.lenght == word2.lenght){
word1 = word1.toLowerCase();
word2 = word2.toLowerCase();
let teste = word1.split('');
let origin = word2.split('');
teste = teste.sort();
origin = origin.sort();
teste = teste.join();
origin = origin.join();
if (teste == origin)
return true;
else
return false;
word1 = word1.toLowerCase();
word2 = word2.toLowerCase();
let teste = word1.split('');
let origin = word2.split('');
teste = teste.sort();
origin = origin.sort();
teste = teste.join();
origin = origin.join();
if (teste == origin)
return true;
else
return false;
}
else return false;
}
else return false;
else
return false;
}
else return false;
}