Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ryan-dia] level 2 문제 풀이 추가 #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Ryan-Dia wants to merge 2 commits into codeisneverodd:main
base: main
Choose a base branch
Loading
from Ryan-Dia:sub
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update 프린터&42587&.js
  • Loading branch information
Ryan-Dia authored Dec 26, 2022
commit d20566480883092044f3a48bf2ea829f48bab5b1
21 changes: 21 additions & 0 deletions level-2/프린터&42587&.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,24 @@ class Queue {
return this.rear - this.front
}
}

// 정답 6 ryan-dia

function solution(priorities, location, result = 0) {
const queue = priorities.map((p, i) => ({ priority: p, index: i }));

while (queue.length > 0) {
const current = queue.shift();
const higherPriority = queue.some((d) => d.priority > current.priority);

if (higherPriority) {
queue.push(current);
continue;
}
result += 1;
if (current.index === location) {
return result;
}
}
}

AltStyle によって変換されたページ (->オリジナル) /