Open
Conversation
Yeonlisa
reviewed
Oct 31, 2021
Comment on lines
+2
to
+4
| const solution = (arr) => { | ||
| return [...new Set(arr)].sort((a, b) => b - a); | ||
| }; |
ganeodolu
reviewed
Oct 31, 2021
| tempArr.sort((a, b) => { | ||
| //국어점수 desc | ||
| if (b[1] > a[1]) return -1; | ||
| else if (b[1 < a[1]]) return 1; |
There was a problem hiding this comment.
else if (b[1 < a[1]]) return 1;
오타 찾았습니당
| .slice(1, n + 1) | ||
| .map((v) => v.split(" ").map((x) => Number(x) || x)); | ||
|
|
||
| tempArr.sort((a, b) => { |
|
|
||
| const failureRates = []; | ||
| let failure; | ||
| let completedPlayersNum = stages.length || 0; |
Contributor
There was a problem hiding this comment.
stages.length 는 항상 0이상이니 || 0은 없어도 되지 않을까요..?
Comment on lines
+16
to
+19
| failure = | ||
| completedPlayersNum == 0 | ||
| ? 0 | ||
| : (failure = count[i] / completedPlayersNum); |
Contributor
There was a problem hiding this comment.
Suggested change
| failure = | |
| completedPlayersNum == 0 | |
| ? 0 | |
| : (failure = count[i] / completedPlayersNum); | |
| const failure = | |
| completedPlayersNum === 0 | |
| ? 0 | |
| : count[i] / completedPlayersNum; |
요렇게 하는건 어떨까요?
| let res = []; | ||
| for (let i = 0; i < count.length; i++) { | ||
| for (let j = count[i]; j >= 0; j--) { | ||
| res = [...res, i]; |
Contributor
There was a problem hiding this comment.
spread operator도 O(N) 이기 때문에, res가 충분히 커진다면 [...res, i]도 꽤 큰 비용일 수 있습니다 🐶
Author
There was a problem hiding this comment.
그렇네요 배열의 길이가 크면 그만큼 다시 밀려서 비용이 커지니 push 낫겠네요. 혹시 더 괜찮은 방법 있으면 알려주세요 !
Contributor
There was a problem hiding this comment.
low-level 한 연산을 수행할 때는 그냥 push 하는게 공간복잡도, 시간복잡도 측면에서 제일 나은거 같아요 😅
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[5주차][정렬][Sue] 학습한 내용 정리입니다