

1) object 도 array 와 같이 복사하면 된다고 생각했는데 복사하면 안됬다.
결국은
2) 문제를 제대로 읽어보지 않은것... > 되는 날짜를 count 해야되는데 그것을 놓쳐서 틀렸다.
딱 보자마자 완전 탐색이구나 싶어서 object 식으로
키를 넣은뒤 키가 존재하지 않으면 break 를 해 시간 복잡도를 줄일려고 했었다.
count 를 사용해서 되는 날짜를 세서 return 한다.
금방 풀어서 다행이다 ..^^
function solution(want, number, discount) {
var answer = 0;
var oj={};
want.map((el,index)=>{oj[el]=number[index]});
for(var i=0; i<discount.length; i++){
var count_copy= {...oj};
var count=0;
for(var ii=i; ii<=i+9; ii++){
if( !count_copy[discount[ii]]){
break;
}
else{
if(count_copy[discount[ii]]>0){
count_copy[discount[ii]]-=1;
if(count_copy[discount[ii]]==0){
count+=1;
}
}
}
}
if(count==number.length){
answer+=1;
//return i+1;
}
}
return answer;
}