Skip to content

[bky373] 10th week solutions #166

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

Merged
merged 5 commits into from
Jul 9, 2024
Merged

[bky373] 10th week solutions #166

merged 5 commits into from
Jul 9, 2024

Conversation

bky373
Copy link
Contributor

@bky373 bky373 commented Jul 3, 2024

@bky373
Copy link
Contributor Author

bky373 commented Jul 3, 2024

아고 드래프트로 올린다는 게 실수로 오픈했네요 일단 드래프트로 변경하겠습니다

@bky373 bky373 marked this pull request as draft July 3, 2024 14:52

/*
* Approach 2.
* time: O(n^2)
Copy link
Contributor

Choose a reason for hiding this comment

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

while (0 <= start && end < s.length() && s.charAt(start) == s.charAt(end)) {
이 부분이 끝까지 가지 않을 확률이 높아서 평균적으로 n^2 보다는 작을 것 같은데
혹시 이 부분도 고려해보셨을까요?

저는 일단

시간 복잡도는 평균적으로 O(n)이다. palindrome 의 길이가 n 에 가까워질수록 시간 복잡도는 O(n^2) 에 가까워 진다.
이렇게 적어보긴 했네요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하 저는 시간 복잡도를 하나의 값으로 설명해야 한다면, 보수적으로 가장 오래 걸리는 경우의 값을 취해야 한다고 생각했습니다!
다만 굳이 하나의 값으로 설명하지 않아도 된다면, 종훈님이 올려주신 아래 문장이 적절해 보이네요!

시간 복잡도는 평균적으로 O(n)이다. palindrome 의 길이가 n 에 가까워질수록 시간 복잡도는 O(n^2) 에 가까워 진다.


start = i;
end = i + 1;
while (0 <= start && end < s.length() && s.charAt(start) == s.charAt(end)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 while 블록이 위에 있는 while 블록과 완전히 동일한것 같은데
맞다면 중복을 제거해보면 어떠실까요?

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 +75 to +80
/*
* Approach 2-2.
* time: 시간 복잡도는 평균적으로 O(n)이고, palindrome 의 길이가 n 에 가까워지면 시간 복잡도 역시 O(n^2) 에 가까워 진다.
* space: O(1)
*/
class Solution {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dev-jonghoonpark
리뷰 주신 부분 여기에 반영했습니다~ 덕분에 코드가 훨씬 깔끔해졌네요!
610f418

@bky373 bky373 marked this pull request as ready for review July 7, 2024 13:40
Copy link
Contributor

@nhistory nhistory left a comment

Choose a reason for hiding this comment

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

수고 많으셨습니다!

@DaleSeo DaleSeo merged commit f518058 into DaleStudy:main Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants