Solución
solution.tsTypeScript
export function groupConsecutiveDuplicates(nums: number[]): number[][] {
if (nums.length === 0) return [];
const answer = [];
const temp = [];
for (let i = 0; i < nums.length; i++) {
const current = nums[i];
if (!temp.includes(current) && temp.length > 0) {
answer.push([...temp]);
temp.length = 0;
}
temp.push(current);
}
if (temp.length > 0) answer.push(temp);
return answer;
}0respuestas