- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 195
[정현준] 9주차 #521
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
[정현준] 9주차 #521
Conversation
* TC: O(log N), SC: O(1) | ||
*/ | ||
fun findMin(nums: IntArray): Int { | ||
var (low, high) = 0 to nums.size - 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.
var (low, high) = 0 to nums.size - 1
kotlin에서 pair를 만드는 표현이 참 특이하네요 ㅎㅎ
while (low + 1 < high) { | ||
val mid = (low + high) / 2 | ||
if (nums[mid - 1] > nums[mid]) { | ||
return nums[mid] | ||
} | ||
if (nums[mid] < nums[high]) { | ||
high = mid | ||
} | ||
else { | ||
low = mid | ||
} | ||
} |
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.
이진탐색 로직이 깔끔하고 좋습니다 ㅎㅎ
저도 현준님 풀이에 영감을 얻어서 제 풀이를 좀 더 다듬을 수 있었습니다 :)
https://github.com/DaleStudy/leetcode-study/pull/520/files#diff-d02da092874d1658e6fb39bb2d7221b29a6fe6804b26e2c460bdd0e2243dd373
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.
전에 obzva님이 전달해주신 이진 검색 정리 게시글을 본게 도움 많이 되었습니다! 감사합니다 ㅎㅎ
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.
안녕하세요 ㅎㅎ 한 주 고생하셨습니다 화이팅입니다 현준님
* TC: O(n * m), SC: O(n * m) | ||
*/ | ||
fun pacificAtlantic(heights: Array<IntArray>): List<List<Int>> { | ||
val (row, col) = heights.size to heights.first().size |
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.
제가 알기로는 가독성 외에는 딱히 다른 장점은 없는걸로 알고있습니다 ㅎㅎ
@jdalma 님, 다음부터 Week 설정 빼먹지 않도록 좀 부탁드리겠습니다. 🙇♂️ |
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.