function solution(n, lost, reserve) {
const hasClothes = Array(n).fill(1);
lost.map((lost) => hasClothes[lost-1] = 0);
reserve.map(reserve => hasClothes[reserve-1] += 1);
for(let i = 0; i < n; i++){
if(hasClothes[i] === 0 && hasClothes[i-1] ===2){
hasClothes[i] = 1;
hasClothes[i-1] = 1;
}
if(hasClothes[i] === 0 && hasClothes[i+1] === 2){
hasClothes[i] = 1;
hasClothes[i+1] = 1;
}
}
return hasClothes.filter(c => c > 0).length;
}