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

[Jeehay28] Week 4 #812

Merged
merged 5 commits into from
Jan 4, 2025
Merged

[Jeehay28] Week 4 #812

merged 5 commits into from
Jan 4, 2025

Conversation

Jeehay28
Copy link
Contributor

@Jeehay28 Jeehay28 commented Dec 29, 2024

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@Jeehay28 Jeehay28 requested a review from a team as a code owner December 29, 2024 12:22
@github-actions github-actions bot added the js label Dec 29, 2024
@Jeehay28 Jeehay28 requested a review from dusunax December 29, 2024 12:23
Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@Jeehay28 님 2024년 한 해 고생 많으셨습니다!
2025년 한 해도 복 많이 받으시길 바라며 리뷰 드렸고, 앞으로도 많은 참여 부탁드려요!
아직 풀이중이시니 코멘트만 남기고 가겠습니다!

// Time complexity: O(n)(two loops: one for numbers 0 to n and one for array elements)
// Space complexity: O(1)

var missingNumber = function (nums) {
Copy link
Contributor

Choose a reason for hiding this comment

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

오.. XOR 풀이도 신기하네요!
이미 복잡도는 최대치이긴 하지만, 아래와 같이 순회하면 순회를 절반으로 줄여서 성능을 거의 두배로 올릴 수 있을것 같은데요?!

for (let i = 0; i < n; i++) {
        xor = xor ^ i ^ nums[i];
    }

Copy link
Member

Choose a reason for hiding this comment

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

고생하셨습니다!
재귀도 효율적이지만 반복문으로 SC를 O(1)로 최적화하는 방법도 추가로 고려해보면 좋을 것 같습니다.

Copy link
Member

@dusunax dusunax Jan 4, 2025

Choose a reason for hiding this comment

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

My own approach부분도 잘 봤습니다
문제의 전제가 중복된 숫자가 없는 배열이라
let distinctNums = new Set(nums);으로 작성해도 동작하네요

Copy link
Member

@dusunax dusunax left a comment

Choose a reason for hiding this comment

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

이번 주도 고생하셨습니다🙂

@Jeehay28 Jeehay28 merged commit 4583f0e into DaleStudy:main Jan 4, 2025
1 check 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