Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions Moonjonghoo/queue/๋กœ๊ทธ์ธ_์„ฑ๊ณต.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function solution(id_pw, db) {
const [id, pw] = id_pw;

for (const [dbId, dbPw] of db) {
if (id === dbId) {
return pw === dbPw ? "login" : "wrong pw";
}
}

return "fail";
}
14 changes: 14 additions & 0 deletions Moonjonghoo/queue/์ˆœ์„œ์Œ์˜_๊ฐœ์ˆ˜.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function solution(n) {
let count = 0;

for (let i = 1; i <= Math.sqrt(n); i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.sqrt(n) ์ƒ๊ฐ๋„ ๋ชปํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

if (n % i === 0) {
count++; // i๊ฐ€ ์•ฝ์ˆ˜
if (i !== n / i) {
count++; // i๊ฐ€ n์˜ ์ œ๊ณฑ๊ทผ์ด ์•„๋‹ˆ๋ฉด ๋‚˜๋จธ์ง€ ์ง๋„ ์ถ”๊ฐ€
}
}
}

return count;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function solution(dot) {
const [x, y] = dot;

if (x > 0 && y > 0) return 1; // 1์‚ฌ๋ถ„๋ฉด
if (x < 0 && y > 0) return 2; // 2์‚ฌ๋ถ„๋ฉด
if (x < 0 && y < 0) return 3; // 3์‚ฌ๋ถ„๋ฉด
if (x > 0 && y < 0) return 4; // 4์‚ฌ๋ถ„๋ฉด
}
11 changes: 11 additions & 0 deletions Moonjonghoo/queue/ํŠน์ดํ•œ_์ •๋ ฌ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function solution(numlist, n) {
return numlist.sort((a, b) => {
const diffA = Math.abs(a - n);
const diffB = Math.abs(b - n);

if (diffA === diffB) {
return b - a;
}
return diffA - diffB;
});
}
17 changes: 17 additions & 0 deletions Moonjonghoo/queue/ํ”„๋กœ์„ธ์Šค.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function solution(priorities, location) {
let order = 0;

while (priorities.length > 0) {
const current = priorities.shift();
if (priorities.some((priority) => priority > current)) {
priorities.push(current);
location = location === 0 ? priorities.length - 1 : location - 1;
} else {
order++;
if (location === 0) {
return order; // ๋ชฉํ‘œ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋˜์—ˆ์„ ๋•Œ ์ˆœ์„œ๋ฅผ ๋ฐ˜ํ™˜
}
location--;
}
}
}
Loading