-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
내장 함수를 사용한 풀이 코드리뷰 부탁드려요
22.04.07 11:19 작성 조회수 121
0
function solution(n,arr) {
let answer = '';
let cash = Array.from({length: n}, ()=>0)
for(let a of arr) {
if(cash.indexOf(a) < 0) {
cash.unshift(a);
cash.pop();
} else {
cash.splice(cash.indexOf(a),1);
cash.unshift(a);
}
}
answer = cash;
return answer;
}
console.log(solution(5, [1,2,3,2,6,2,3,5,7]))
답변을 작성해보세요.
0
답변 1