Solución
solution.tsTypeScript
function runLengthEncoding(text: string): string {
let count = 0;
let result = [];
for ( let i : number = 0; i < text.length; i++ ){
if ( text[i] === text[i+1] ) {
count+=1
result.splice(i, 1, '')
} else {
count+=1
result.push(count+text[i])
count = 0
}
}
return result.join('');
}
// No modificar: necesario para evaluar el resultado.
export { runLengthEncoding };0respuestas