-
Notifications
You must be signed in to change notification settings - Fork 4
[tkddbs587] 25.01.16 #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
469f794
String calculation / ๊ธฐ์ด
tkddbs587 cdccf6a
fork ๋ ํฌ์์ ํด๋ ์ฎ๊น
tkddbs587 ab5c5c4
Control z / ๊ธฐ์ด
tkddbs587 172c35e
I_hate_english / ๊ธฐ์ด
tkddbs587 693370b
String_reversal / ๊ธฐ์ด
tkddbs587 4ff7262
Valid_parentheses / ์ค๊ธ
tkddbs587 c056834
Crane_claw_machine_game / ์ค๊ธ
tkddbs587 87fb22f
Number_of_ordered_pairs / ๊ธฐ์ด
tkddbs587 6434863
Merge branch 'main' of https://github.com/codingTestStd/CoteAndAlgoriโฆ
tkddbs587 725a718
Dart_game / ์ค๊ธ
tkddbs587 330d680
Find_point_position / ๊ธฐ์ด
tkddbs587 e44fd74
Card_bundle / ์ค๊ธ
tkddbs587 e445d28
Login_success / ๊ธฐ์ด
tkddbs587 e2795a6
Make_burger / ์ค๊ธ
tkddbs587 5898301
Set_treatment_order / ๊ธฐ์ด
tkddbs587 986ae4a
Ranking / ๊ธฐ์ด
tkddbs587 27626e2
Make_b_from_a / ๊ธฐ์ด
tkddbs587 cf66aeb
Morse_code / ๊ธฐ์ด
tkddbs587 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| function solution(arr, divisor) { | ||
| let newArr = arr.filter((el) => el % divisor === 0); // ๋๋์ด ๋จ์ด์ง๋ ์๋ฆฌ๋จผํธ๊ฐ ๋ด๊ธด ์ ๋ฐฐ์ด ๋ฐํ | ||
|
|
||
| // ๋๋์ด ๋จ์ด์ง๋ ์๋ฆฌ๋จผํธ ์์ผ๋ฉด ๊ทธ๋ฅ [-1] ๋ฐํ | ||
| if (newArr.length === 0) { | ||
| return [-1]; | ||
| } | ||
|
|
||
| return newArr.sort((a, b) => a - b); // ์ค๋ฆ์ฐจ์ ์ ๋ ฌ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function solution(strlist) { | ||
| return strlist.map((str) => str.length); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| function solution(before, after) { | ||
| // 1. ๋ฌธ์์ด์ ๋ฐฐ์ด๋ก ๋ณํ | ||
| // 2. ์ค๋ฆ์ฐจ์ ์ ๋ ฌ | ||
| // 3. ์ ๋ ฌํ ๋ฐฐ์ด ๋ฌธ์์ด๋ก ๋ณํ ํ ๋น๊ต | ||
| return before.split("").sort().join("") === after.split("").sort().join("") | ||
| ? 1 | ||
| : 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| function solution(letter) { | ||
| // ๋ชจ์ค ๋ถํธ ๊ฐ์ฒด | ||
| morse = { | ||
| ".-": "a", | ||
| "-...": "b", | ||
| "-.-.": "c", | ||
| "-..": "d", | ||
| ".": "e", | ||
| "..-.": "f", | ||
| "--.": "g", | ||
| "....": "h", | ||
| "..": "i", | ||
| ".---": "j", | ||
| "-.-": "k", | ||
| ".-..": "l", | ||
| "--": "m", | ||
| "-.": "n", | ||
| "---": "o", | ||
| ".--.": "p", | ||
| "--.-": "q", | ||
| ".-.": "r", | ||
| "...": "s", | ||
| "-": "t", | ||
| "..-": "u", | ||
| "...-": "v", | ||
| ".--": "w", | ||
| "-..-": "x", | ||
| "-.--": "y", | ||
| "--..": "z", | ||
| }; | ||
|
|
||
| // letter์ ๋ชจ์ค ๋ถํธ๊ฐ ๊ณต๋ฐฑ ๊ธฐ์ค์ผ๋ก ๋๋ ์ ธ์์ผ๋ฏ๋ก split๋ฅผ ํตํด ๋ฐฐ์ด๋ก ๋ณํ | ||
| // ๋ณํ๋ ๋ฐฐ์ด์ map์ ํตํด ์ํํ๋ฉฐ morse ๊ฐ์ฒด์ ํค์ ์ผ์นํ๋ ์์ด ๋ฌธ์์ด value๋ก ์ด๋ฃจ์ด์ง ์ ๋ฐฐ์ด ๋ฐํ | ||
| // ์์ด ๋ฐฐ์ด์ join์ ํตํด ๋ฌธ์์ด๋ก ๋ณํ | ||
| return letter | ||
| .split(" ") | ||
| .map((el) => morse[el]) | ||
| .join(""); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| function solution(score) { | ||
| // score์ ํ๊ท ์ ์ ๊ตฌํ๊ธฐ | ||
| let average = score.map((el) => (el[0] + el[1]) / 2); | ||
|
|
||
| // ํ๊ท ์ ๋ด๋ฆผ์ฐจ์์ผ๋ก ์ ๋ ฌํ ๋ฐฐ์ด ์ ์ธ slice() ํตํด average ๋ฐฐ์ด ์์ ๋ณต์ฌ(์๋ณธ ๋ฐฐ์ด์ ๋ณ๊ฒฝ๋์ง ์์) | ||
| let sortedAverage = average.slice().sort((a, b) => b - a); | ||
|
|
||
| // average์ ์์์ ๋์ผํ sortedAverage ๋ฐฐ์ด์ index ๊ฐ์ 1์ ๋ํ๊ธฐ | ||
| return average.map((el) => sortedAverage.indexOf(el) + 1); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function solution(emergency) { | ||
| let sorted = [...emergency].sort((a, b) => b - a); // ๋ฐฐ์ด ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ | ||
|
|
||
| return emergency.map((v) => sorted.indexOf(v) + 1); | ||
| // ๊ธฐ์กด ๋ฐฐ์ด์ ๊ฐ ์์๋ฅผ ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ๋ ๋ฐฐ์ด์ ๋งค์นญ๋๋ ์์๋ก ์ ๊ทผํ์ฌ index + 1 ๋ก ์์๋๋ก ์์ ๋งค๊ธฐ๊ณ map() ๋ฉ์๋๋ฅผ ํตํด ์์๊ฐ ๋ด๊ธด ์ ๋ฐฐ์ด ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| function solution(cards1, cards2, goal) { | ||
| let index1 = 0; // ์นด๋1์ ์ธ๋ฑ์ค | ||
| let index2 = 0; // ์นด๋2์ ์ธ๋ฑ์ค | ||
|
|
||
| for (let i = 0; i < goal.length; i++) { | ||
| if (cards1[index1] === goal[i]) { | ||
| // ์นด๋1์ ์ธ๋ฑ์ค 0๋ถํฐ ์์๋๋ก ๊ณจ์ ์ธ๋ฑ์ค i์ ๊ฐ์ผ๋ฉด | ||
| index1++; // ์นด๋ 1์ ์ธ๋ฑ์ค 1 ์ฆ๊ฐ | ||
| } else if (cards2[index2] === goal[i]) { | ||
| // ์นด๋2์ ์ธ๋ฑ์ค 0๋ถํฐ ์์๋๋ก ๊ณจ์ ์ธ๋ฑ์ค i์ ๊ฐ์ผ๋ฉด | ||
| index2++; // ์นด๋ 2์ ์ธ๋ฑ์ค 1 ์ฆ๊ฐ | ||
| } else return "No"; // ์์๋๋ก ๋น๊ตํ๋ค๊ฐ ๋ ์ด์ ์ผ์นํ๋ ์ธ๋ฑ์ค๊ฐ ์์ผ๋ฉด ๋ง๋ค ์ ์๋ ๋ฌธ์ฅ์ด๋ฏ๋ก No ๋ฐํ | ||
| } | ||
| return "Yes"; // goal์ ์ธ๋ฑ์ค๋งํผ ์ํ๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ๋ง์น๋ฉด ๋ฌธ์ฅ์ ๋ง๋ค ์ ์์ผ๋ฏ๋ก Yes ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| function solution(dot) { | ||
| const [x, y] = dot; // x, y ๊ฐ | ||
|
|
||
| if (Math.sign(x) === 1) { | ||
| // x๊ฐ์ด ์์์ผ๋ | ||
| if (Math.sign(y) === 1) { | ||
| // y๊ฐ๋ ์์๋ฉด | ||
| return 1; // 1์ฌ๋ถ๋ฉด | ||
| } else { | ||
| return 4; // x๊ฐ์ ์์๊ณ y๊ฐ์ ์์ -> 4์ฌ๋ถ๋ฉด | ||
| } | ||
| } | ||
|
|
||
| if (Math.sign(x) === -1) { | ||
| // x๊ฐ์ด ์์์ผ๋ | ||
| if (Math.sign(y) === -1) { | ||
| // y๊ฐ๋ ์์๋ฉด | ||
| return 3; // 3์ฌ๋ถ๋ฉด | ||
| } else { | ||
| return 2; // y๊ฐ์ ์์๊ณ x๊ฐ์ ์์ -> 2์ฌ๋ถ๋ฉด | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| function solution(id_pw, db) { | ||
| const [id, pw] = id_pw; // ์์ด๋, ํจ์ค์๋ ๋ถ๋ฆฌ | ||
| const map = new Map(db); // db๋ฅผ ๊ธฐ๋ฐ์ผ๋ก Map ๊ฐ์ฒด ์์ฑ | ||
| console.log(map); | ||
|
|
||
| if (map.has(id)) { | ||
| // map ๊ฐ์ฒด์ id ๊ฐ ์์๋ | ||
| if (map.get(id) === pw) { | ||
| // ์์ด๋์ ํจ์ค์๋๊ฐ ์ผ์นํ๋ฉด | ||
| return "login"; // 'login' ๋ฐํ | ||
| } else return "wrong pw"; // ์์ด๋๋ ๊ฐ์๋ฐ ํจ์ค์๋๋ง ํ๋ฆฌ๋ฉด 'wrong pw' ๋ฐํ | ||
| } else return "fail"; // ๋ ๋ค ํ๋ฆฌ๋ฉด 'fail' ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| function solution(ingredient) { | ||
| let stack = []; // ์คํ | ||
| let count = 0; // ํ๋ฒ๊ฑฐ ํฌ์ฅ ๊ฐฏ์ | ||
| for (let i = 0; i < ingredient.length; i++) { | ||
| stack.push(ingredient[i]); // ingredient ์ธ๋ฑ์ค ์์๋๋ก ์คํ์ ์ถ๊ฐ | ||
| if (stack.length >= 4) { | ||
| // ์คํ์ ์ฌ๋ฃ๊ฐ 4๊ฐ ์ด์ ์์์๋ | ||
| const hamburger = stack.slice(-4).join(""); // ์คํ์ ๋์์๋ถํฐ 4๊ฐ์ ์์ ๋ฌธ์์ด๋ก ์ถ์ถ | ||
|
|
||
| if (hamburger === "1231") { | ||
| // ์ถ์ถํ ๋ฌธ์์ด์ด 1231 ์์์ ์ผ์นํ๋ฉด | ||
| count++; // ํฌ์ฅ ๊ฐฏ์ 1 ์ฆ๊ฐ | ||
| stack.splice(-4); // ์คํ์์ ํฌ์ฅ๋ ํ๋ฒ๊ฑฐ ์ ๊ฑฐ | ||
| } | ||
| } | ||
| } | ||
| return count; // ์ด ํฌ์ฅ ๊ฐฏ์ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| function solution(n) { | ||
| let count = 0; | ||
|
|
||
| for (let i = 1; i <= n; i++) { | ||
| if (n % i === 0) { | ||
| // n์ ์ฝ์ ๊ตฌํ๊ธฐ | ||
| count++; // ์ฝ์ ๊ตฌํ ๋๋ง๋ค ์นด์ดํธ์ | ||
| } | ||
| } | ||
|
|
||
| return count; // ์์์ ๊ฐฏ์ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| function solution(s) { | ||
| let answer = 0; | ||
| const arr = s.split(" "); // ๊ณต๋ฐฑ์ ๊ธฐ์ค์ผ๋ก ๋ฌธ์์ด์ ๋ฐฐ์ด๋ก ๋ณํ | ||
| for (let i = 0; i < arr.length; i++) { | ||
| if (arr[i] !== "Z") { | ||
| // ๋ฐฐ์ด ์์๊ฐ 'Z' ๊ฐ ์๋๋ฉด | ||
| answer += Number(arr[i]); // Number ํ์ ์ผ๋ก ๋ณํ ํ ๋ณ์์ ๋ํ๊ธฐ | ||
| } else { | ||
| answer -= Number(arr[i - 1]); // 'Z' ๋ฉด ํ์ฌ ์ธ๋ฑ์ค ํ๋ ์ ์ธ๋ฑ์ค์ ์ซ์ ๋นผ๊ธฐ | ||
| } | ||
| } | ||
| return answer; // ์ต์ข ์ซ์ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| function solution(board, moves) { | ||
| // 2์ฐจ์ ๋ฐฐ์ด board๋ฅผ ๊ฐ ์ด๋ง๋ค ์คํ ์์ฑ 5x5์ผ ๊ฒฝ์ฐ ์ด 5๊ฐ์ ์คํ ์์ฑ | ||
| let stack = [...Array(board[0].length)].map(() => []); | ||
|
|
||
| for (let i = board.length - 1; i >= 0; i--) { | ||
| for (let j = 0; j < board[0].length; j++) { | ||
| if (board[i][j] !== 0) { | ||
| // 0์ด ์๋๋๋ง ๊ฐ ์คํ์ ์ถ๊ฐ | ||
| stack[j].push(board[i][j]); // ์คํ์ ๊ฐ ์ด์ ๋ง์ถฐ board์ ์์๋ค ์ถ๊ฐ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let removeCount = 0; | ||
| let bucket = []; | ||
|
|
||
| for (let m of moves) { | ||
| if (stack[m - 1].length > 0) { | ||
| // ์คํ์ ์ด์ ์ธํ์ด ์กด์ฌํ๋ฉด | ||
| const doll = stack[m - 1].pop(); // ๋งจ ์์ ์ธํ ์ง์ด์ | ||
| // ๋ฐ๊ตฌ๋์ ์ธํ์ด ์๊ณ ๋งจ ์์ ์ธํ์ด ์ง๊ธ ๋ฃ์ผ๋ ค๋ ์ธํ๊ณผ ๊ฐ์ผ๋ฉด | ||
| if (bucket.length > 0 && bucket[bucket.length - 1] === doll) { | ||
| bucket.pop(); // ๋ฐ๊ตฌ๋ ๋งจ ์์ ์ธํ ์ ๊ฑฐ | ||
| removeCount += 2; // ์ ๊ฑฐํ ๊ฐฏ์ 2๊ฐ ์ถ๊ฐ | ||
| } else { | ||
| bucket.push(doll); // ๋ฐ๊ตฌ๋์ ์ธํ์ด ์๊ฑฐ๋ ๋งจ ์ ์ธํ๊ณผ ๊ฐ์ง ์์ ์ธํ์ด๋ฉด ์ถ๊ฐ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return removeCount; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| function solution(d) { | ||
| let arr = d.split(""); | ||
| let stack = []; | ||
| let score = 0; | ||
|
|
||
| for (let i = 0; i < arr.length; i++) { | ||
| if (!isNaN(arr[i])) { | ||
| if (arr[i] === "1" && arr[i + 1] === "0") { | ||
| // ์ ์๊ฐ 10์ธ ๊ฒฝ์ฐ | ||
| score = 10; // ์ด ์ค์ฝ์ด์ 10์ ์ถ๊ฐ | ||
| i++; // 0 ๊ฑด๋๋ฐ๊ธฐ | ||
| } else score = arr[i]; | ||
| } else if (arr[i] === "S") { | ||
| stack.push(Math.pow(score, 1)); // Single -> 1์ ๊ณฑ | ||
| } else if (arr[i] === "D") { | ||
| stack.push(Math.pow(score, 2)); // Double -> 2์ ๊ณฑ | ||
| } else if (arr[i] === "T") { | ||
| stack.push(Math.pow(score, 3)); // Triple -> 3์ ๊ณฑ | ||
| } else if (arr[i] === "#") { | ||
| // ์์ฐจ์์ผ ๊ฒฝ์ฐ | ||
| stack[stack.length - 1] *= -1; // ํด๋น ์ ์ ๋นผ๊ธฐ | ||
| } else if (arr[i] === "*") { | ||
| // ์คํ์์ผ ๊ฒฝ์ฐ | ||
| stack[stack.length - 1] *= 2; // ํด๋น ์ ์ 2๋ฐฐ | ||
| stack[stack.length - 2] *= 2; // ๋ฐ๋ก ์ ์ ์๋ 2๋ฐฐ | ||
| } | ||
| } | ||
|
|
||
| let result = 0; | ||
| for (let i = 0; i < stack.length; i++) { | ||
| result += stack[i]; // ์ด ์ ์ ๊ตฌํ๊ธฐ | ||
| } | ||
|
|
||
| return result; // ์ด ์ ์ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| function solution(numbers) { | ||
| let numArr = [ | ||
| "zero", | ||
| "one", | ||
| "two", | ||
| "three", | ||
| "four", | ||
| "five", | ||
| "six", | ||
| "seven", | ||
| "eight", | ||
| "nine", | ||
| ]; // 0 ~ 9 ๋ฐฐ์ด ์์ฑ | ||
| let strNum = ""; // ์ซ์๋ฅผ ๋ฌธ์์ด๋ก ํํํ numbers๋ฅผ ์ธ๋ฑ์ค ์์๋๋ก ๋ด์ ๋ณ์ | ||
| let result = ""; // ์ซ์ ๋จ์ด์ ํด๋นํ๋ ์ซ์๋ฅผ ๋ด์ ๋ณ์ | ||
| for (let i = 0; i < numbers.length; i++) { | ||
| strNum += numbers[i]; // ๋ณ์์ numbers ์ธ๋ฑ์ค ์์๋๋ก ๋ด๊ธฐ | ||
|
|
||
| if (numArr.includes(strNum)) { | ||
| // ์ฐจ๋ก๋๋ก ๋ด๋ค๊ฐ ๋ฐฐ์ด์ ํด๋นํ๋ ์ซ์๊ฐ ์์ผ๋ฉด | ||
| result += numArr.indexOf(strNum); // ํด๋น ์ซ์ ์ธ๋ฑ์ค๋ฅผ ๋ณ์์ ์ถ๊ฐ | ||
| strNum = ""; // numbers์ ์๋ ๋ค์ ์ซ์ ๋จ์ด๋ฅผ ๋ํด์ฃผ๊ธฐ ์ํด ์ด๊ธฐํ | ||
| } | ||
| } | ||
| return Number(result); // ๋ฌธ์์ด๋ก ๋ผ์๋ ์ซ์ ๋ณ์๋ฅผ number ํ์ ์ผ๋ก ๋ณํ ํ ๊ฒฐ๊ณผ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| function solution(my_string) { | ||
| let arr = my_string.split(" "); // ๊ณต๋ฐฑ์ ๊ธฐ์ค์ผ๋ก ๋ฐฐ์ด ์์ฑ | ||
| console.log(arr); | ||
| let result = Number(arr[0]); // 0๋ฒ ์ธ๋ฑ์ค ์ซ์๋ก ๋ณํ = ์ฒซ๋ฒ์งธ ์ซ์ ๊ตฌํ๊ณ | ||
| for (let i = 1; i < arr.length; i += 2) { | ||
| // ํ์ ์ธ๋ฑ์ค ์ ๊ทผ = ์ฐ์ฐ์์ ์ ๊ทผ | ||
| let operator = arr[i]; // ํ์ฌ ์ฐ์ฐ์ | ||
| let NextNum = Number(arr[i + 1]); // ์ฐ์ฐ์ ์ค๋ฅธ์ชฝ ์ซ์ | ||
| if (operator === "+") { | ||
| // ์ฐ์ฐ์๊ฐ + ๋ฉด ๋ํ๊ณ | ||
| result += NextNum; | ||
| } else { | ||
| result -= NextNum; // - ๋ฉด ๋นผ๊ธฐ | ||
| } | ||
| } | ||
| return result; // ๊ฒฐ๊ณผ ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| function solution(str) { | ||
| var answer = ""; | ||
| for (let i = str.length - 1; i >= 0; i--) { | ||
| // ๋ฌธ์์ด ๋ณ์ str์ ๋ง์ง๋ง ์ธ๋ฑ์ค๋ถํฐ ํ๊ธ์์ฉ ์ ๊ทผ | ||
| answer += str[i]; // ๋ฌธ์์ด ๋ณ์ answer์ ์ถ๊ฐ | ||
| } | ||
| return answer; // ๋ค์ง์ ๋ฌธ์์ด ๋ฐํ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| function solution(s) { | ||
| let stack = []; // ์คํ | ||
| let arr = s.split(""); // ๊ดํธ ๋ณ๋ก ์๋ผ์ ๋ฐฐ์ด ์์ฑ | ||
| for (let i = 0; i < arr.length; i++) { | ||
| if (arr[i] === "(") { | ||
| // ์ด๋ฆฐ ๊ดํธ์ผ๋ | ||
| stack.push(arr[i]); // ์คํ์ ์ด๋ฆฐ ๊ดํธ ์ถ๊ฐ | ||
| } else { | ||
| // ๋ซํ ๊ดํธ์ผ๋ | ||
| stack.pop(); // ์คํ์ ์์๋ ์ด๋ฆฐ ๊ดํธ ์ ๊ฑฐ | ||
| } | ||
| } | ||
| if (stack.length === 0) { | ||
| // ์คํ์ด ๋น์ด์์ผ๋ฉด ์ง์ด ๋ง๋ค๋ ๋ป์ด๋ฏ๋ก length๊ฐ 0 | ||
| return true; // ๊ฒฐ๊ณผ ๋ฐํ | ||
| } else { | ||
| return false; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด๋ฐ์์ผ๋ก ์ค์์น ๋ฌธ์ ์ฌ์ฉํด์ ํํํ๋ ๋ฐฉ๋ฒ๋ ์์ด์!