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

[정현준] 9주차 #521

Merged
merged 3 commits into from
Oct 11, 2024
Merged

[정현준] 9주차 #521

merged 3 commits into from
Oct 11, 2024

Conversation

jdalma
Copy link
Member

@jdalma jdalma commented Oct 7, 2024

답안 제출 문제

체크 리스트

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

* TC: O(log N), SC: O(1)
*/
fun findMin(nums: IntArray): Int {
var (low, high) = 0 to nums.size - 1
Copy link
Contributor

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를 만드는 표현이 참 특이하네요 ㅎㅎ

Comment on lines +9 to +20
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
}
}
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

전에 obzva님이 전달해주신 이진 검색 정리 게시글을 본게 도움 많이 되었습니다! 감사합니다 ㅎㅎ

@jdalma jdalma marked this pull request as ready for review October 11, 2024 08:44
@jdalma jdalma requested a review from a team as a code owner October 11, 2024 08:44
Copy link
Contributor

@obzva obzva 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 * m), SC: O(n * m)
*/
fun pacificAtlantic(heights: Array<IntArray>): List<List<Int>> {
val (row, col) = heights.size to heights.first().size
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
Member Author

Choose a reason for hiding this comment

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

제가 알기로는 가독성 외에는 딱히 다른 장점은 없는걸로 알고있습니다 ㅎㅎ

@jdalma jdalma merged commit aeb29c4 into DaleStudy:main Oct 11, 2024
1 check passed
@DaleSeo
Copy link
Contributor

DaleSeo commented Oct 12, 2024

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

@jdalma 님, 다음부터 Week 설정 빼먹지 않도록 좀 부탁드리겠습니다. 🙇‍♂️

Shot 2024-10-11 at 21 25 26@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants