Skip to content

[seunghyun] Week 2 Solutions #65

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 1 commit into from
May 12, 2024
Merged

[seunghyun] Week 2 Solutions #65

merged 1 commit into from
May 12, 2024

Conversation

koreas9408
Copy link
Contributor

@koreas9408 koreas9408 commented May 11, 2024

2주차 문제풀이

  1. Valid Parentheses
  2. Reverse Linked List
  3. Merge Two Sorted Lists
  4. Linked List Cycle
  5. Invert Binary Tree

현생이슈로 풀이가 많이 늦었습니다 🙏🙏
링크드 리스트에 대한 이해도가 낮아서 자료구조를 더 공부해야겠네요 ㅠㅠ

Copy link
Contributor

@SamTheKorean SamTheKorean left a comment

Choose a reason for hiding this comment

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

바쁘신 와중에 이렇게 올려주신 것만으로 대단합니다. 고생하셨습니다.

@leokim0922
Copy link
Contributor

저도 Linked List 문제를 좋아하지 않습니다. 포인터를 활용해서 수정하는 것 자체가 조금 직관적으로 와닿지가 않아서 더 헷갈리는거 같아요. 저는 처음에 이해가 안가면 링크드리스트를 표를 그려서 실제로 코드에서 포인터가 어떻게 옮겨가는지 제가 직접 체크를 해봤습니다. 안해보셨다면 이 방법을 한 번 시도해보세요 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

해당 솔루션만 시/공간 복잡도 누락된 것 같습니다 😄

ListNode node2 = node1.next;
head.next = null;

while (node1 != null && node2 != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

요 부분에서 굳이 node1 까지 확인한 이유가 혹시 있을까요? 위에 이미 head로 지정을 해놓으셔서 이미 while 루프에 들어간 리스트는 list1이 null 이 아님을 확인한 상태인거 같아서요!

Copy link
Contributor

Choose a reason for hiding this comment

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

재귀로 접근하신게 신선한 것 같네요...! : )

if (stack.isEmpty()) return false;

if (c == ')') {
Character pop = stack.pop();
Copy link
Contributor

Choose a reason for hiding this comment

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

stack pop 부분이 각 조건문 안에서 반복되어서
빼볼 수 있지 않았을까 하는 생각이 드네요

@DaleSeo DaleSeo added the week2 label May 12, 2024
@leokim0922 leokim0922 merged commit 78c7981 into DaleStudy:main May 12, 2024
1 check passed
@DaleSeo DaleSeo added this to the week2 milestone May 12, 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.

5 participants