✨ 문제 ✨

✨ 정답 ✨
function solution(priorities, location) {
var answer = 0;
let locationNumber=priorities[location];
priorities[location]='this'
let isDone=false
while(isDone===false){
let tempArray=priorities.slice();
tempArray[priorities.indexOf('this')]=locationNumber
let max=Math.max(...tempArray);
if ( tempArray.indexOf(max)===priorities.indexOf('this')&& locationNumber>=max){
answer+=1;
isDone=true;
}else{
let indexIs=priorities.indexOf(max);
let front=priorities.splice(0, indexIs);
priorities.shift();
priorities=[...priorities, ...front]
answer+=1;
}
}
return answer;
}
🧵 참고한 정답지 🧵
💡💡 기억해야 할 점 💡💡