-
Notifications
You must be signed in to change notification settings - Fork 3
Week 39 문제풀이
#209
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
Week 39 문제풀이
#209
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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,13 @@ | ||
| function solution(my_string, index_list) { | ||
| let result = ""; | ||
| for(let i = 0; i < index_list.length; i++) { | ||
| a = index_list[i] | ||
| result += my_string[a]; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| // 다른 풀이 | ||
| function solution(my_string, index_list) { | ||
| return index_list.map(i => my_string[i]).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,19 @@ | ||
| function solution(s) { | ||
| let count = 0; | ||
| for (const char of s.toUpperCase()) { | ||
yuj2n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (char === 'P') count++; | ||
| else if (char === 'Y') count--; | ||
| } | ||
| return count === 0; | ||
| } | ||
|
|
||
| // 다른 풀이 | ||
| function solution(s) { | ||
| const upperS = s.toUpperCase(); | ||
| // 각각의 개수를 변수에 담아 비교하면 가독성이 훨씬 좋아짐! | ||
| const pCount = upperS.split("P").length - 1; | ||
| const yCount = upperS.split("Y").length - 1; | ||
| // 만일 p가 2개면 | ||
|
|
||
| return pCount === yCount; | ||
| } | ||
yuj2n marked this conversation as resolved.
Show resolved
Hide resolved
|
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,4 @@ | ||
| function solution(my_string, is_prefix) { | ||
| // boolean 앞에 + 해주면 true는 1, false는 0으로 변환 | ||
| return +my_string.startsWith(is_prefix); | ||
yuj2n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.