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 06 Solutions #462

Merged
merged 7 commits into from
Sep 21, 2024
Merged

[재호] WEEK 06 Solutions #462

merged 7 commits into from
Sep 21, 2024

Conversation

wogha95
Copy link
Contributor

@wogha95 wogha95 commented Sep 15, 2024

답안 제출 문제

체크 리스트

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

@wogha95 wogha95 added the js label Sep 15, 2024
@wogha95 wogha95 self-assigned this Sep 15, 2024
Comment on lines +23 to +40
// 1. s의 길이만큼 순회를 하면서
for (const char of s) {
// 2. 열린 괄호라면 stack에 짝지어진 닫힌 괄호를 저장
// 3. 닫힌 괄호라면 stack에서 꺼낸 것과 동일한지 확인
switch (char) {
case "(":
case "{":
case "[":
stack.push(map[char]);
break;
case "}":
case ")":
case "]":
if (stack.pop() !== char) {
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.

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

괄호 문제에서 switch 쓸 생각은 못해봤는데 신선하네요!

@wogha95 wogha95 marked this pull request as ready for review September 18, 2024 05:07
@wogha95 wogha95 requested a review from a team as a code owner September 18, 2024 05:07
@wogha95 wogha95 requested a review from obzva September 18, 2024 05:07
Comment on lines +76 to +79
const ROW = matrix.length;
const COLUMN = matrix[0].length;
// 우하좌상 순서
const DIRECTION = [
Copy link
Member

Choose a reason for hiding this comment

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

이렇게 상수로 선언한 덕분에 가독성이 확 올라가는 군요. 감사합니다☺️

Copy link
Member

@sounmind sounmind left a comment

Choose a reason for hiding this comment

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

전반적으로 코드 가독성이 아주 좋다고 생각했어요. 변수 선언도 변수 이름도 명확하고 주석으로 추가 설명까지 잘 해주셔서 알고리즘을 이해하는데 손색 없었습니다 🙇‍♂️


/**
* TC: O(N)
* SC: O(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

addWord 는 단어 길이에 비례해 공간을 사용하는 것 같은데, 상수인 이유가 있을까용?

Copy link
Contributor Author

@wogha95 wogha95 Sep 21, 2024

Choose a reason for hiding this comment

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

제가 순간적으로 linked list로 착각했었네요 😅
O(N)으로 수정해두었습니다!

Comment on lines +23 to +40
// 1. s의 길이만큼 순회를 하면서
for (const char of s) {
// 2. 열린 괄호라면 stack에 짝지어진 닫힌 괄호를 저장
// 3. 닫힌 괄호라면 stack에서 꺼낸 것과 동일한지 확인
switch (char) {
case "(":
case "{":
case "[":
stack.push(map[char]);
break;
case "}":
case ")":
case "]":
if (stack.pop() !== char) {
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.

괄호 문제에서 switch 쓸 생각은 못해봤는데 신선하네요!

}
}

return Math.max(...longestLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

마지막에 Math.max를 통해 longestLength배열의 최대값을 구하는 것보다 for 문 안에서 최대값을 갱신해주는 것이 연산량이 줄어들 것 같아요

Copy link
Contributor Author

@wogha95 wogha95 Sep 21, 2024

Choose a reason for hiding this comment

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

마지막 순회를 줄일수 있네요!
수정해서 반영했습니다!
감사합니다~!

@wogha95 wogha95 merged commit ce9ec5d into DaleStudy:main Sep 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

4 participants