문제
풀이 과정
queue를 이용해서 문제를 해결한다.
const solutionA = (priorities, location) => {
let count = 0;
while (priorities.length > 0) {
const firstEl = priorities.shift();
count++;
let isCheck = false;
for (let priority of priorities) {
if (firstEl < priority) {
priorities.push(firstEl);
isCheck = true;
count--;
break;
}
}
if (location === 0 && !isCheck) return count;
else location -= 1;
if (location < 0) location = priorities.length - 1;
}
return count;
};
const testA = solutionA([1, 1, 9, 1, 1, 1], 0);
console.log(testA);
틀린 부분이 있거나 보충해야 할 내용이 있다면 댓글이나 DM(sungstonemin)으로 알려주시면 감사하겠습니다😄