Skip to content

Conversation

Sunjae95
Copy link
Member

@Sunjae95 Sunjae95 commented Oct 6, 2024

답안 제출 문제

체크 리스트

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

@Sunjae95 Sunjae95 self-assigned this Oct 6, 2024
@github-actions github-actions bot added the js label Oct 6, 2024
Copy link
Contributor

@wogha95 wogha95 left a comment

Choose a reason for hiding this comment

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

9주차 모든 문제 푸시느라 고생 많으셨습니다~!!
문제는 다 푸셨지만 Draft 상태 변경을 잊으신지 아닌가 싶어서 먼저 리뷰 남겨드립니다! 📝

Comment on lines +24 to +29
if (answer < nums[nums.length - 1]) return answer;

for (let i = nums.length - 1; i >= 0; i--) {
if (answer < nums[i]) return answer;
answer = nums[i];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

answer < nums[nums.length - 1] 조건문이 for문 안에 있는 if문에 포함되어 제거 가능해보입니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

오호?! 그러네요 중복되는 로직이었군요..!
감사합니다.

*
* n = length of height
* m = length of height[i]
* time complexity: O(n*m * 4^n*m)
Copy link
Contributor

Choose a reason for hiding this comment

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

상하좌우에 대한 4방향 접근으로 인해 4^n*m으로 계산하신걸까요?
visited 를 사용해서 memoization 하니 각 방향이n*m만큼 탐색일까 하는 의문이 듭니다!
혹시 가능하시다면 시간 복잡도 계산 과정 설명 부탁드립니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

안녕하세요. @wogha95 님! 리뷰 코멘트가 늦어진점 죄송합니다🥲

코멘트에 대한 리뷰는 다음과 같아요!
pacific이며 atlantic인 경우에만 memization이 되도록 구현했어요.
그래서 각 인덱스마다 접근시 memization이 안되는 경우가 존재하며 최악의 상황의 시간복잡도는 O(nm * 4^nm) 으로 계산했어요.
추가로 visited는 전역에서 사용하는 변수이지만 해당 bfs 스코프에서 다룰수 있게 값을 설정하여 매번 4방향을 탐색하도록 동작하도록 구현했어요.
그래서 제가 계산한 시간복잡도는 O(nm * 4^nm) 인데 이해가 됐을까요?

@Sunjae95 Sunjae95 marked this pull request as ready for review October 12, 2024 13:25
@Sunjae95 Sunjae95 requested a review from a team as a code owner October 12, 2024 13:25
@Sunjae95 Sunjae95 merged commit 0b457eb into DaleStudy:main Oct 12, 2024
1 check passed
@DaleSeo
Copy link
Member

DaleSeo commented Oct 17, 2024

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요

@Sunjae95 님, Week 설정 좀 까먹지 말고 좀 부탁드립니다 🥲

Shot 2024-10-17 at 18 44 24@2x

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.

3 participants