-
Notifications
You must be signed in to change notification settings - Fork 120
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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
이 제약 사항으로 명시되었으니 이 체크는 불필요할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇네요! 습관적으로 적은것 같습니다. 주의해야겟네요 감사합니다!
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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와, 이 알고리즘 굉장히 창의적인 것 같은데 모임 때 소개해주실 수 있으실까요?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
시간 복잡도를 어떻게 분석하셨는지 설명 좀 부탁드리겠습니다.
There was a problem hiding this comment.
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)
이 될 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9주차 hard 문제까지 모두 푸시느라 고생 많으셨습니다!
깔끔하게 코드를 작성해주셔서 로직을 이해하기 수월했습니다~!!👍
There was a problem hiding this 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); |
There was a problem hiding this comment.
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);
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.