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

[Tony] WEEK 09 Solutions #518

Merged
merged 5 commits into from
Oct 12, 2024
Merged

[Tony] WEEK 09 Solutions #518

merged 5 commits into from
Oct 12, 2024

Conversation

TonyKim9401
Copy link
Contributor

@TonyKim9401 TonyKim9401 commented Oct 6, 2024

답안 제출 문제

체크 리스트

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

@TonyKim9401 TonyKim9401 changed the title Linked List Cycle [Tony] WEEK 09 Solutions Oct 6, 2024
@TonyKim9401 TonyKim9401 requested a review from wogha95 October 7, 2024 00:56
@TonyKim9401 TonyKim9401 marked this pull request as ready for review October 10, 2024 17:11
@TonyKim9401 TonyKim9401 requested a review from a team as a code owner October 10, 2024 17:11
@TonyKim9401 TonyKim9401 requested a review from DaleSeo October 11, 2024 22:26
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.

수고하셨습니다!

public List<List<Integer>> pacificAtlantic(int[][] heights) {
List<List<Integer>> output = new ArrayList<>();

if (heights.length == 0 || heights[0].length == 0) return output;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 1 <= m, n <= 200이 제약 사항으로 명시되었으니 이 체크는 불필요할 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그렇네요! 습관적으로 적은것 같습니다. 주의해야겟네요 감사합니다!

Comment on lines +15 to +21
if (nums[start] <= nums[mid]) {
min = Math.min(min, nums[start]);
start = mid + 1;
} else if (nums[mid] <= nums[end]) {
min = Math.min(min, nums[mid]);
end = mid - 1;
}
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,52 @@
// TC: 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.

외부 while의 경우 s의 길이 만큼 반복하니 O(n)이 되구요.
내부 while의 경우 항상 실행되는 것이 아니라 각 문자가 슬라이딩 윈도우에 한번 추가되고, 최대 한번만 제거되기 때문에 시간 복잡도에 크게 영향을 미치지 않을거라 생각합니다.
정확하게 계산한다면 O(n + m) 이 될 것 같습니다!

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주차 hard 문제까지 모두 푸시느라 고생 많으셨습니다!
깔끔하게 코드를 작성해주셔서 로직을 이해하기 수월했습니다~!!👍

@TonyKim9401 TonyKim9401 merged commit 9a8decb into DaleStudy:main Oct 12, 2024
1 check passed
Copy link
Contributor

@bky373 bky373 left a comment

Choose a reason for hiding this comment

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

가독성이 좋게 풀어주셨네요! 매주 토니님 코드를 보고 설명을 들으며 많이 배우고 있습니다
이번 주도 고생 많으셨습니다!


while (right < s.length()) {
char c = s.charAt(right);
windowCounts.put(c, windowCounts.getOrDefault(c, 0) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

(사소) Map.merge(..) 메서드를 사용하여 Map 접근 횟수도 줄이고 좀더 간단하게 작성할 수도 있습니다~

windowCounts.merge(c, 1, Integer::sum);

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