-
Notifications
You must be signed in to change notification settings - Fork 3
Week 47 문제풀이
#413
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 47 문제풀이
#413
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e20e40a
chore: 중앙값 상수화
yuj2n f5600a3
solve: 꼬리 문자열
yuj2n cac7fa1
solve: 0 떼기
yuj2n b6a4844
solve: 제일 작은 수 제거하기
yuj2n 4df830b
chore: 꼬리문자열 다른풀이 추가
yuj2n a979398
chore: 불필요한 반복 방지를 위한 새 변수 생성
yuj2n be8a614
chore: 값 추가마다 새 문자열 생성으로 메모리 공간 할당되는 문제 해결을 위한 배열화
yuj2n 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 |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| function solution(s) { | ||
| return s.length % 2 === 0 | ||
| ? s[s.length / 2 - 1] + s[s.length / 2] | ||
| : s[Math.floor(s.length / 2)]; | ||
| const mid = s.length / 2; | ||
| return s.length % 2 === 0 ? s[mid - 1] + s[mid] : s[Math.floor(mid)]; | ||
| } | ||
|
|
||
| // 다른 풀이 | ||
| // function solution(s) { | ||
| // return s.substr(Math.ceil(s.length / 2) - 1, s.length % 2 ? 1 : 2); | ||
| // const mid = Math.floor(s.length / 2); | ||
| // // 짝수면 mid-1부터 mid+1까지(2글자), 홀수면 mid부터 mid+1까지(1글자) | ||
| // return s.length % 2 !== 0 ? s.slice(mid, mid + 1) : s.slice(mid - 1, mid + 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,24 @@ | ||
| function solution(n_str) { | ||
| let result = []; | ||
| let foundFirstNonZero = false; | ||
|
|
||
| for (let i = 0; i < n_str.length; i++) { | ||
| // 0이 아닌 숫자 처음 발견 & 그 자리가 0이 아닌 경우 | ||
| // 0이면 넘어가서 안 담기도록 | ||
| if (!foundFirstNonZero && n_str[i] !== "0") { | ||
| foundFirstNonZero = true; | ||
| } | ||
|
|
||
| // 0이 아닌 숫자 처음 발견 이후 모든 문자 담기 | ||
| if (foundFirstNonZero) { | ||
| result.push(n_str[i]); | ||
| } | ||
| } | ||
|
|
||
| return result.join(""); | ||
| } | ||
|
|
||
| // 다른 풀이 | ||
| // function solution(n_str) { | ||
| // return String(Number(n_str)); | ||
| // } |
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(str_list, ex) { | ||
| let answer = ""; | ||
| str_list.forEach((list) => { | ||
| answer += list.includes(ex) ? "" : list; | ||
| }); | ||
| return answer; | ||
| } | ||
|
|
||
| // 다른 풀이 | ||
| function solution(str_list, ex) { | ||
| // filter는 true를 거르는게 아닌 true를 포함시킴 | ||
| return str_list.filter((str) => !str.includes(ex)).join(""); | ||
| } |
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(arr) { | ||
| let min = Math.min(...arr); | ||
| return arr.length <= 1 ? [-1] : arr.filter((n) => n !== min); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.