-
Notifications
You must be signed in to change notification settings - Fork 120
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
[재호] WEEK 02 Solutions #339
Conversation
* @return {boolean} | ||
*/ | ||
var isAnagram = function(s, t) { | ||
return s.split('').sort().join('') === t.split('').sort().join(''); |
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.
오..... 나누고 정렬하고 합치고 좋네요 배워갑니다!
construct-binary-tree-from-preorder-and-inorder-traversal/wogha95.js
Outdated
Show resolved
Hide resolved
요런 좋은 질문은 디스커션에 올려주시면 다른 분들도 생각할 기회가 생겨서 좋을 것 같습니다! |
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.
수고하셨습니다! 몇 가지 코멘트 남겼지만 PR을 승인해드리는데는 문제가 되지 않을 것 같습니다.
var countBits = function (n) { | ||
const result = [0]; | ||
let pointer = 0; | ||
let lastPointer = 0; | ||
|
||
for (let num = 1; num <= n; num++) { | ||
result.push(result[pointer] + 1); | ||
|
||
if (pointer === lastPointer) { | ||
lastPointer = result.length - 1; | ||
pointer = 0; | ||
} else { | ||
pointer += 1; | ||
} | ||
} | ||
|
||
return result; | ||
}; |
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.
이 투포인터 솔루션 신기한 것 같은데, 혹시 모임 때 소개해주실 수 있으실까요?
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.
달레님 알고리즘과 크게 다를 바 없다고 생각해서 조금 의아했는데 소개 이유를 들어보니 깨닫게 되었습니다!
그리고 갑작스럽게 발표준비하다보니 두서없이 설명드린것 같아서 걱정되었는데 부족한 부분 피드백 주셔서 감사합니다 :)
@@ -0,0 +1,33 @@ | |||
// TC: O(N) - leetcode analyze 기준 |
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.
복잡도 분석은 직접하시는 게 더 좋을 것 같습니다! 코딩 면접 때도 직접 하셔야하니까요 :)
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.
넵, leetcode analyze complexity에 의존하지 않고 직접 계산해보겠습니다!
@@ -0,0 +1,33 @@ | |||
// TC: O(N) - leetcode analyze 기준 | |||
// SC: O(N) |
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.
혹시 배열 복재에 들어가는 메모리도 고려하셨을까요?
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.
평상시에 시간복잡도만 계산하고 공간복잡도는 대략적으로만 생각했는데 배열 복제의 메모리 사용도 고려해야하는지 몰랐습니다.. 😮
알고달레 블로그 확인해서 많이 도움 받았습니다 :) 감사합니다~!
O(N)
에다가 findIndex 순회O(N)
이 중첩되어 있으니O(N^2)
로 생각했는데 leetcode analyze 에서는 시간복잡도를O(N)
으로 알려줍니다. 혹시 제가 시간복잡도 계산을 잘못한 것일까요?