-
Notifications
You must be signed in to change notification settings - Fork 4
[oh-chaeyeon] 25.01.09 #21
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
21 commits
Select commit
Hold shift + click to select a range
2c03149
배열 자르기 / 기초
oh-chaeyeon b307f95
배열 원소의 길이 / 기초
oh-chaeyeon 280b794
배열 회전시키기 / 기초
oh-chaeyeon 2465ff2
중복된 숫자 개수 / 기초
oh-chaeyeon 9b120c8
제일 작은 수 제거하기 / 중급
oh-chaeyeon e54d44a
행렬의 덧셈 / 중급
oh-chaeyeon 7f618bf
나누어 떨어지는 숫자 배열 / 중급
oh-chaeyeon 121d553
행렬의 곱셈 / 심화
oh-chaeyeon 1c9229c
교점에 별 만들기 / 심화
oh-chaeyeon 865c257
n^2 배열 자르기 / 심화
oh-chaeyeon ea88f07
String Reversal / 기초
oh-chaeyeon 3f26859
Control Z / 기초
oh-chaeyeon a8c82b3
Hate English / 기초
oh-chaeyeon 4a4f3f2
String Calculation / 기초
oh-chaeyeon d30a080
Crane Game / 중급
oh-chaeyeon a560deb
Valid Parentheses / 중급
oh-chaeyeon 7dadd5d
Dart Game / 중급
oh-chaeyeon b2fdfc6
Rotate Parentheses / 심화
oh-chaeyeon e00f4cd
Stock Price / 심화
oh-chaeyeon 9bd1415
Delivery Box / 심화
oh-chaeyeon 92aa4e2
Merge branch 'main' into ohchaeyeon
oh-chaeyeon 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,14 @@ | ||
| function solution(s) { | ||
| const elements = s.split(" "); | ||
| let total = 0; | ||
|
|
||
| for (let i = 0; i < elements.length; i++) { | ||
| if (elements[i] === "Z") { | ||
| total -= parseInt(elements[i - 1]); | ||
| } else { | ||
| total += parseInt(elements[i]); | ||
| } | ||
| } | ||
|
|
||
| return total; | ||
| } |
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,25 @@ | ||
| function solution(board, moves) { | ||
| const basket = []; | ||
| let count = 0; | ||
|
|
||
| for (let move of moves) { | ||
| const column = move - 1; | ||
|
|
||
| for (let i = 0; i < board.length; i++) { | ||
| if (board[i][column] !== 0) { | ||
| const doll = board[i][column]; | ||
| board[i][column] = 0; | ||
|
|
||
| if (basket[basket.length - 1] === doll) { | ||
| basket.pop(); | ||
| count += 2; | ||
| } else { | ||
| basket.push(doll); | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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,24 @@ | ||
| function solution(dartResult) { | ||
| const stack = []; | ||
| let i = 0; | ||
|
|
||
| while (i < dartResult.length) { | ||
| const isTen = dartResult[i] === "1" && dartResult[i + 1] === "0"; | ||
| let score = isTen ? 10 : parseInt(dartResult[i]); | ||
| i += isTen ? 2 : 1; | ||
|
|
||
| const bonus = dartResult[i++]; | ||
| score **= bonus === "S" ? 1 : bonus === "D" ? 2 : 3; | ||
|
|
||
| if (dartResult[i] === "*" || dartResult[i] === "#") { | ||
| score *= dartResult[i] === "*" ? 2 : -1; | ||
| if (dartResult[i++] === "*" && stack.length) { | ||
| stack[stack.length - 1] *= 2; | ||
| } | ||
| } | ||
|
|
||
| stack.push(score); | ||
| } | ||
|
|
||
| return stack.reduce((sum, cur) => sum + cur, 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,18 @@ | ||
| function solution(order) { | ||
| let stack = []; | ||
| let current = 1; | ||
| let count = 0; | ||
|
|
||
| for (let box of order) { | ||
| while (current <= box) { | ||
| stack.push(current++); | ||
| } | ||
| if (stack.pop() === box) { | ||
| count++; | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| 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,22 @@ | ||
| function solution(numbers) { | ||
| return parseInt( | ||
| numbers.replace( | ||
| /zero|one|two|three|four|five|six|seven|eight|nine/g, | ||
| (match) => { | ||
| const numWords = { | ||
| zero: "0", | ||
| one: "1", | ||
| two: "2", | ||
| three: "3", | ||
| four: "4", | ||
| five: "5", | ||
| six: "6", | ||
| seven: "7", | ||
| eight: "8", | ||
| nine: "9", | ||
| }; | ||
| return numWords[match]; | ||
| } | ||
| ) | ||
| ); | ||
| } | ||
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,25 @@ | ||
| function solution(s) { | ||
| let answer = 0; | ||
| for (let i = 0; i < s.length; i++) { | ||
| const rotated = s.slice(i) + s.slice(0, i); | ||
| if (isValid(rotated)) answer++; | ||
| } | ||
| return answer; | ||
| } | ||
|
|
||
| function isValid(str) { | ||
| const stack = []; | ||
| for (let c of str) { | ||
| if ("([{".includes(c)) stack.push(c); | ||
| else if (!stack.length || !isPair(stack.pop(), c)) return false; | ||
| } | ||
| return stack.length === 0; | ||
| } | ||
|
|
||
| function isPair(open, close) { | ||
| return ( | ||
| (open === "(" && close === ")") || | ||
| (open === "[" && close === "]") || | ||
| (open === "{" && close === "}") | ||
| ); | ||
| } |
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(prices) { | ||
| const answer = Array(prices.length).fill(0); | ||
| const stack = []; | ||
|
|
||
| prices.forEach((price, i) => { | ||
| while (stack.length && prices[stack[stack.length - 1]] > price) { | ||
| const idx = stack.pop(); | ||
| answer[idx] = i - idx; | ||
| } | ||
| stack.push(i); | ||
| }); | ||
|
|
||
| stack.forEach((idx) => { | ||
| answer[idx] = prices.length - 1 - idx; | ||
| }); | ||
|
|
||
| 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,3 @@ | ||
| function solution(my_string) { | ||
| return eval(my_string); | ||
| } |
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(my_string) { | ||
| return my_string.split("").reverse().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,15 @@ | ||
| function solution(s) { | ||
| const stack = []; | ||
|
|
||
| for (let char of s) { | ||
| if (char === "(") { | ||
| stack.push(char); | ||
| } else if (stack.length > 0) { | ||
| stack.pop(); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return stack.length === 0; | ||
| } |
Oops, something went wrong.
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.
정규식을활용하여 코드가 직관적이라 좋았습니다!