Skip to content

Ejercicios 10 de Noviembre

Arrays

Fácil

Cree una función que tome un array de elementos y verifique si el último elemento coincide con el resto del array concatenado.

Ejemplos

matchLastItem(["i", "love", "tesh", "ilovetesh"]) ➞ true

matchLastItem(["i", "am", "into", "her", "world", "iamintoherworld"]) ➞ true

matchLastItem(["1", "1", "1", "11"]) ➞ false

matchLastItem(["12", "13", "17", "19", "20", "40", "121317192040"]) ➞ true

Intermedio

Cree una función que cuente la cantidad de veces que aparece una letra en particular en la búsqueda de palabras.
letterCounter([
["D", "E", "Y", "H", "A", "D"],
["C", "B", "Z", "Y", "J", "K"],
["D", "B", "C", "A", "M", "N"],
["F", "G", "G", "R", "S", "R"],
["V", "X", "H", "A", "S", "S"] ], "D") ➞ 3

letterCounter([
["D", "E", "Y", "H", "A", "D"],
["C", "B", "Z", "Y", "J", "K"],
["D", "B", "C", "A", "M", "N"],
["F", "G", "G", "R", "S", "R"],
["V", "X", "H", "A", "S", "S"] ], "H") ➞ 2

Difícil

Escriba una función que devuelva verdadero si puede dividir un array en un elemento y el resto, de modo que este elemento sea igual al producto de todos los demás elementos, excluyéndose a sí mismo.
canPartition([2, 8, 4, 1]) ➞ true
// 8 = 2 x 4 x 1
canPartition([-1, -10, 1, -2, 20]) ➞ false

canPartition([-1, -20, 5, -1, -2, 2]) ➞ true
El array puede contener duplicados. Pueden existir múltiples soluciones, con que una devuelva true es suficiente.

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.