-
-
Notifications
You must be signed in to change notification settings - Fork 195
[bus710] Week 07 #928
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
[bus710] Week 07 #928
Conversation
문제 1번의 경우 주어진 리스트를 쭉 순회하며 각 요소의 값을 새 요소에 복사한 후 그 새 요소의 next를 이 전에 생성했던 요소로 지정하는 방식을 사용함으로써 시간 복잡도를 O(n)으로 유지할 수 있도록 시도해봤습니다. 다만 그에 상응해 공간을 더 사용하게 되어서 공간 복잡도는 O(2n)이 되었습니다. 둘 다 만족하거나 상황에 따라 절충하는 방법을 찾으면 좋겠습니다. 나머지 풀이는 가급적 차차 추가하도록 하겠습니다. |
시간이 통 안나네요 ㅠㅠ |
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,26 @@ | |||
package hello |
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.
문제 풀이를 할 때 테스트를 먼저 작성하는 편인데, 패키지 이름을 짧게 적다보니 이렇게 되었습니다 ㅎㅎ
head2 := &ListNode{} | ||
|
||
if head == nil { | ||
return nil | ||
} |
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.
숏컷 로직이 제일 상단에 위치하는게 좋을 것 같아요
head2 := &ListNode{} | |
if head == nil { | |
return nil | |
} | |
if head == nil { | |
return nil | |
} | |
head2 := &ListNode{} |
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.
그리고 head2
보다 더 나은 이름이 있을 것 같아요
이 변수가 뭐하는 녀석인지 바로 와닿지가 않았습니다
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.
반복문 내에서 계속 새로운 ListNode struct instance를 생성하는 것은 공간 복잡도 측면에서 효율적이지 않습니다
포인터만을 이용하는 것을 추천드립니다 :)
제가 제안하는 솔루션 또한 첨부합니다, 정 생각이 안 나시거나 바쁘실 때 참고해주세요 (https://gist.github.com/obzva/c5f726474e844e076270aad523acc39e)
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.