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 9 Solution #519

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

[강희찬] WEEK 9 Solution #519

wants to merge 6 commits into from

Conversation

HC-kang
Copy link
Contributor

@HC-kang HC-kang commented Oct 6, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@HC-kang HC-kang marked this pull request as ready for review October 9, 2024 23:39
@HC-kang HC-kang requested a review from a team as a code owner October 9, 2024 23:39
function findMin(nums: number[]): number {
let left = 0;
let right = nums.length - 1;
let mid = (left + right) >> 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

mid 값 구하는데 (left + right) / 2만 생각했는데, 이렇게 하면 비트 연산으로 더 효율적이겠네요..! 하나 배웠습니다 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

// 2 보다 우아하네요. mid에 대해 첨언드리자면 정수형 변수의 크기가 가변적이지 않은 언어의 경우 left + (right - left) // 2 같은 방식으로 mid를 계산해서 overflow를 방지하는 방식도 있습니다.

Copy link
Contributor

@TonyKim9401 TonyKim9401 left a comment

Choose a reason for hiding this comment

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

9주차 문제 풀이 고생 많으셨습니다~!

Comment on lines +15 to +22
function hasCycle(head: ListNode | null): boolean {
const SET = new Set<ListNode>();
while (head) {
if (SET.has(head)) return true;
SET.add(head);
head = head.next
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

fast와 slow만 사용하는걸 생각헀는데, 창의적인 답인것 같아요!

Comment on lines +7 to +15
function maxSubArray(nums: number[]): number {
let maxSum = nums[0];

for (let i = 1; i < nums.length; i++) {
nums[i] = Math.max(nums[i], nums[i] + nums[i - 1]);
maxSum = Math.max(maxSum, nums[i]);
}

return maxSum;
Copy link
Contributor

Choose a reason for hiding this comment

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

성능만 따지자면 세개의 답중 가장 느리고 공간 효율도 안좋지만, 가독성 측면에서 봤을때는 너무 좋은것 같아요. 개인적으로 이 코드가 제일 마음에 들어요 :)

Comment on lines +68 to +69
* T.C. O(m * n)
* S.C. O(m * n)
Copy link
Contributor

Choose a reason for hiding this comment

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

시간 복잡도를 ^2이나 줄이시는 과정이 눈에 보여서 좋은것 같아요 :)
희찬의 경우에는 pacific, atlantic에서 공통 좌표를 가지고 있으면 추가해주는 식으로 하셨는데, 전 각각 boolean 타입의 배열을 만들어서, 둘다 true면 추가해주는 식으로 헀어요. 큰 차이는 없지만 제 풀이 코드도 확인해주시면 재미있으실것 같습니다 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants