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

[Helena] Week 1 solutions #48

Merged
merged 2 commits into from
May 5, 2024
Merged

[Helena] Week 1 solutions #48

merged 2 commits into from
May 5, 2024

Conversation

yolophg
Copy link
Contributor

@yolophg yolophg commented May 4, 2024

Included as follows :

  • Contains Duplicate
  • Valid Anagram
  • Two Sum
  • Valid Palindrome
  • Best Time to Buy and Sell Stock

@dev-jonghoonpark
Copy link
Contributor

마지막 줄에 line break를 추가해주시면 좋을것 같습니다...!
https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline

@dev-jonghoonpark
Copy link
Contributor

각 풀이의 시간복잡도와 공간복잡도 도 적어주시면 좋을것 같습니다...!

@yolophg yolophg changed the title [Helena] Week 1 solutions [Helena] Week 1 solutions and valid-parentheses for Week 2 solutions May 5, 2024
@yolophg yolophg changed the title [Helena] Week 1 solutions and valid-parentheses for Week 2 solutions [Helena] Week 1 solutions and Valid parentheses for Week 2 solutions May 5, 2024
@yolophg yolophg changed the title [Helena] Week 1 solutions and Valid parentheses for Week 2 solutions [Helena] Week 1 solutions May 5, 2024
@yolophg
Copy link
Contributor Author

yolophg commented May 5, 2024

마지막 줄에 line break를 추가해주시면 좋을것 같습니다...! https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline

반영하였습니다, 감사합니다 :)

Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. @dev-jonghoonpark의 피드백처럼 복잡도 분석도 해주시면 더욱 좋을 것 같네요 😄

secondList = t.split("").sort();

// compare if these are same and return
return JSON.stringify(firstList) === JSON.stringify(secondList);
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
Contributor

Choose a reason for hiding this comment

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

솔루션 잘 봤습니다! 저도 처음 문제를 풀었을 때 sort 해서 비교하는 방식으로 문제를 풀었었는데요. 해당 방법이 간단하고 원라인코드로 작성가능한 점은 좋으나 sort 때문에 시간복잡도가 n logn이 되는 단점이 있습니다! O(n)으로도 풀이가 가능하니 해당 방법도 도전해보시면 좋을거 같습니다 :)

Copy link
Contributor

@Invidam Invidam left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 👍👍

주석으로 설명들을 많이 남겨주셔서 이해가 잘되었어요!
리뷰어분들의 이해를 돕기 위해 주석을 쓰시는 건가요? 저는 평소에 거의 주석을 안달아서 궁금하네요!!

Comment on lines +2 to +3
firstList = s.split("").sort();
secondList = t.split("").sort();
Copy link
Contributor

Choose a reason for hiding this comment

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

split("")이 있어야 배열(문자들의 배열)로 바뀌어 계산이 되는거군요 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

저는 Set을 이용하여 문자가 몇 번 등장했는지 유지한 후 비교하도록 했어요~
Set을 사용하는 건 정렬보다 낮은 시간복잡도라는 장점이 있을 것 같아요!

@DaleSeo DaleSeo added this to the week1 milestone May 5, 2024
@DaleSeo DaleSeo added the week1 label May 5, 2024
@SamTheKorean SamTheKorean merged commit 83ad247 into DaleStudy:main May 5, 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.

6 participants