Skip to content
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

Merged
merged 8 commits into from
Aug 25, 2024
Merged

[재호] WEEK 02 Solutions #339

merged 8 commits into from
Aug 25, 2024

Conversation

wogha95
Copy link
Contributor

@wogha95 wogha95 commented Aug 18, 2024

@wogha95 wogha95 self-assigned this Aug 18, 2024
@wogha95 wogha95 added the js label Aug 18, 2024
* @return {boolean}
*/
var isAnagram = function(s, t) {
return s.split('').sort().join('') === t.split('').sort().join('');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오..... 나누고 정렬하고 합치고 좋네요 배워갑니다!

@DaleSeo
Copy link
Contributor

DaleSeo commented Aug 21, 2024

  • preorder 순회 O(N) 에다가 findIndex 순회 O(N) 이 중첩되어 있으니 O(N^2)로 생각했는데 leetcode analyze 에서는 시간복잡도를 O(N)으로 알려줍니다. 혹시 제가 시간복잡도 계산을 잘못한 것일까요?

요런 좋은 질문은 디스커션에 올려주시면 다른 분들도 생각할 기회가 생겨서 좋을 것 같습니다!

@wogha95 wogha95 marked this pull request as ready for review August 24, 2024 11:31
Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다! 몇 가지 코멘트 남겼지만 PR을 승인해드리는데는 문제가 되지 않을 것 같습니다.

Comment on lines +8 to +25
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;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 투포인터 솔루션 신기한 것 같은데, 혹시 모임 때 소개해주실 수 있으실까요?

Copy link
Contributor Author

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 기준
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

복잡도 분석은 직접하시는 게 더 좋을 것 같습니다! 코딩 면접 때도 직접 하셔야하니까요 :)

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 배열 복재에 들어가는 메모리도 고려하셨을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

평상시에 시간복잡도만 계산하고 공간복잡도는 대략적으로만 생각했는데 배열 복제의 메모리 사용도 고려해야하는지 몰랐습니다.. 😮
알고달레 블로그 확인해서 많이 도움 받았습니다 :) 감사합니다~!

@wogha95 wogha95 merged commit a5dbbde into DaleStudy:main Aug 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants