Skip to content

[WEEK08-2] 추슬기#39

Merged
doitchuu merged 4 commits into
pnt-fe-study:mainfrom
doitchuu:doitchuu
Apr 7, 2026
Merged

[WEEK08-2] 추슬기#39
doitchuu merged 4 commits into
pnt-fe-study:mainfrom
doitchuu:doitchuu

Conversation

@doitchuu
Copy link
Copy Markdown
Member

@doitchuu doitchuu commented Apr 3, 2026

이렇게 풀었어요

1. Palindrome Linked List

  • 문제를 풀었어요.
  • 풀이 시간 : 20분

1) 복잡도 계산

  • 시간 복잡도: O(n)
  • 공간 복잡도: O(n)

2) 접근 아이디어

  1. 연결 리스트를 한 번 순회하면서 값을 스택에 모두 저장했다.
  2. 다시 head부터 순회하면서 스택에서 꺼낸 값과 현재 노드 값을 비교했다.
  3. 하나라도 다르면 false를 반환하고, 끝까지 같으면 회문이라고 판단했다.

3) 회고

스택으로 푸는 방식은 비교적 직관적이라 바로 구현할 수 있었는데,
다른 사람 풀이를 보니 결국 투포인터 방식이 더 효율적인 풀이인 것 같았다.

다른 사람 풀이:

var isPalindrome = function(head) {
    // 1. 중간 찾기
    let slow = head;
    let fast = head;

    while (fast && fast.next) {
        slow = slow.next;
        fast = fast.next.next;
    }

    // 2. 뒤 절반 뒤집기
    let prev = null;
    let current = slow;

    while (current) {
        let next = current.next;
        current.next = prev;
        prev = current;
        current = next;
    }

    // 3. 비교
    let left = head;
    let right = prev;

    while (right) {
        if (left.val !== right.val) {
            return false;
        }
        left = left.next;
        right = right.next;
    }

    return true;
};

다른 사람 풀이 핵심: fast/slow 포인터로 중간을 찾고, 뒤 절반을 뒤집은 뒤 앞 절반과 비교해서 추가 배열 없이 확인하는 방식이었다.
내 생각: 투포인터 방식이 더 효율적일 것 같은데, 그 방식으로 계속 안 풀다 보니 어떻게 적용해야 할지가 아직 잘 안 잡힌다. 계속 노출시키면서 익숙해져야 할 것 같다.



2. Move Zeroes

  • 문제를 풀었어요.
  • 풀이 시간 : 39분

1) 복잡도 계산

  • 시간 복잡도: O(n)
  • 공간 복잡도: O(1)

2) 접근 아이디어

  1. 0이 아닌 값이 나올 때마다 앞쪽 index 위치로 옮겼다.
  2. 필요한 값만 앞쪽에 순서대로 모은 뒤 index를 증가시켰다.
  3. 남은 구간은 전부 0으로 채워 배열을 완성했다.

3) 회고

0이 아닌 숫자를 앞쪽에 순서대로 다시 배치하고, 남은 자리를 0으로 채우는 방식으로 풀 수 있었다.

이 방식은 swap보다 더 직관적이고, 구현 실수도 적은 편이라 지금 단계에서는 훨씬 안정적으로 느껴졌다.

문제를 풀면서도 결국 핵심은

  1. 필요한 값만 앞으로 모은다
  2. 나머지는 0으로 채운다
    이 두 줄로 정리되는 문제였던 것 같다.


@doitchuu doitchuu self-assigned this Apr 3, 2026
@doitchuu doitchuu requested review from raejun92 and sik9252 April 3, 2026 01:03
raejun92
raejun92 previously approved these changes Apr 3, 2026
Copy link
Copy Markdown
Collaborator

@raejun92 raejun92 left a comment

Choose a reason for hiding this comment

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

잘 푸셨군요! 고생하셨습니다~

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

역시 배열로 푸셨군요!
투 포인터를 금방 떠올리기가 쉽지 않은 것 같아요ㅠ

Align README with the revised study rhythm: three Programmers
problems due by Wednesday night, Thursday lunch review/replay,
and occasional SQL add-ons. Keep PR title guidance compatible
with the existing automation flow so the documented process does
not drift from the current script behavior.

Constraint: Scope limited to README documentation only
Rejected: Rename PR title format now | would diverge from current automation script
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: If the automation workflow changes away from [WEEKNN-1], update the README and tooling together
Tested: README diff review; searched README for removed Tuesday/Friday/4-problem wording
Not-tested: Automation script behavior
Remove the Codex automation CLI section that was accidentally
included with the README schedule update. The document should
stay centered on the study process itself without personal tool
usage notes.

Constraint: Preserve the new weekly study schedule wording
Rejected: Leave the CLI section in place | user wants README limited to study guidance
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep personal automation notes out of the shared study README unless explicitly requested
Tested: README grep for removed CLI/script wording
Not-tested: Any automation tooling behavior
Comment thread doitchuu/MoveZeroes.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

저랑 완전 풀이가 같네요!!!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

역시 배열! ㅋㅋㅋ 배열에 값을 저장한 뒤 뒤에서부터 꺼내 비교하는 방식이라 직관적으로 잘 구현하신 것 같습니다~!

@doitchuu doitchuu merged commit fedf7d4 into pnt-fe-study:main Apr 7, 2026
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