Solución
solution.tsTypeScript
export function removeConsecutiveDuplicates(numbers: number[]): number[] {
// Usa while para recorrer el array y eliminar duplicados consecutivos
const length = numbers.length;
const withoutDuplicates = [];
let index = 0;
while ( index < length ) {
if( numbers[index] === numbers [index + 1]) {
index++;
continue;
}
withoutDuplicates.push( numbers[index] );
index++;
}
return withoutDuplicates;
}0respuestas