Skip to content

[WEEK05-1] 최준호#18

Merged
raejun92 merged 2 commits intomainfrom
raejun
Mar 11, 2026
Merged

[WEEK05-1] 최준호#18
raejun92 merged 2 commits intomainfrom
raejun

Conversation

@raejun92
Copy link
Collaborator

@raejun92 raejun92 commented Mar 9, 2026

이렇게 풀었어요

1. Majority Element

  • 문제를 풀었어요.
  • 풀이 시간 : 문제 풀지 못함

1) 복잡도 계산

시간 복잡도: O(n log n)


2) 접근 아이디어

  1. 배열을 정렬한 후에 풀이하려고 했다.
  2. start는 배열의 첫 번째 요소로 초기화하고, end는 배열의 마지막 요소로 초기화했다.
  3. 배열을 순회하면서 start와 다른 요소가 나오면, 그 요소로 start를 업데이트하고, max를 업데이트했다.
  4. end와 같은 요소가 나오면, max를 업데이트하고 반복문을 종료했다.

3) 회고

max의 역할을 헷갈려 풀이를 하지 못하였다.
그냥 Map을 이용해서 요소의 개수를 세는 방식으로 풀이하면 더 간단하게 풀이할 수 있었을 것 같다.



2. Reverse Linked List

  • 문제를 풀었어요.
  • 풀이 시간 : 문제 풀지 못함

1) 복잡도 계산

시간 복잡도: O(n)


2) 접근 아이디어

  1. 새로운 노드를 생성해서 링크드 리스트를 뒤집는 방식으로 풀이하려고 했다.
  2. head = head.next 한 뒤에, 그 다음 루프에서 head = head.next를 할 때 이미 head.next를 바꿔버려 문제가 생겼다.

3) 회고

다른 사람들의 풀이를 보면, prev, cur, next를 이용해서 풀이한 것을 볼 수 있다.
prev는 이전 노드를 가리키고, cur는 현재 노드를 가리키고, next는 다음 노드를 가리킨다.
루프를 돌면서 cur.next를 prev로 바꿔주고, prev와 cur를 한 칸씩 이동시키는 방식으로 풀이한다.



Copy link
Collaborator

@sik9252 sik9252 left a comment

Choose a reason for hiding this comment

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

전체적으로는 두 문제 모두 풀이 방향을 고민한 흔적이 잘 보이네요! 어차피 연습하자고 하는거니까 고민하는 시간에 1시간 이상 소요되면 그냥 답안 보고 이렇게 푸는구나만 알고 가도 나중에 도움될 것 같아요 ㅎㅎ

Copy link
Member

@doitchuu doitchuu left a comment

Choose a reason for hiding this comment

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

at 메소드 등 메소드를 잘 활용하시는군요...! 👍

@raejun92 raejun92 merged commit 4ec2f2a into main Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants