Solución
solution.tsTypeScript
function runLengthEncoding(text: string): string {
// Escribe tu solución aquí
let exit: string [] = [];
for(let i = 0; i < text.length; i++){
let j: number = i;
let count: number = 0;
while(text[i] === text[j]){
j++;
count++;
}
i = j - 1;
exit.push(`${count}${text[i]}`);
}
return exit.join("");
}
// No modificar: necesario para evaluar el resultado.
export { runLengthEncoding };0respuestas