Skip to content

[Chanz] WEEK 07 Solutions - #2803

Merged
parkhojeong merged 2 commits into
DaleStudy:mainfrom
Chanz82:week-07
Aug 9, 2026
Merged

[Chanz] WEEK 07 Solutions#2803
parkhojeong merged 2 commits into
DaleStudy:mainfrom
Chanz82:week-07

Conversation

@Chanz82

@Chanz82 Chanz82 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

Chanz82 added 2 commits August 4, 2026 23:54
Implement a solution to find the length of the longest substring without repeating characters.
@dalestudy

dalestudy Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📊 Chanz82 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
longest-substring-without-repeating-characters Medium ✅ 의도한 유형
reverse-linked-list Easy ✅ 의도한 유형

누적 학습 요약

  • 풀이한 문제: 20 / 75개
  • 이번 주 유형 일치율: 100% (2문제 중 2문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Array ■■■■□□□ 6 / 10 (Easy 3, Medium 3)
String ■■■■□□□ 5 / 10 (Medium 2, Easy 3)
Dynamic Programming ■■□□□□□ 3 / 11 (Easy 1, Medium 2)
Matrix ■■□□□□□ 1 / 4 (Medium 1)
Tree ■■□□□□□ 3 / 14 (Medium 2, Easy 1)
Binary ■□□□□□□ 1 / 5 (Easy 1)
Linked List ■□□□□□□ 1 / 6 (Easy 1)
Graph □□□□□□□ 0 / 8 ← 아직 시작 안 함
Interval □□□□□□□ 0 / 5 ← 아직 시작 안 함
Heap □□□□□□□ 0 / 3 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 662 86 748 $0.000068

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

longest-substring-without-repeating-characters/Chanz82.py
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        left = 0
        max_len = 0
        visited = {}

        for right, ch in enumerate(s):
            if ch in visited and visited[ch] >= left: 
                left = visited[ch] + 1 # 현재 윈도우 상에서 중복 문자가 발견되었기 때문에 윈도우를 중복 문자 이후로 옮김.
            
            visited[ch] = right
            max_len = max(max_len, right - left + 1)

        return max_len
  • 패턴: Two Pointers, Hash Map / Hash Set, Sliding Window
  • 설명: 왼쪽 포인터와 오른쪽 포인터로 창을 유지하며, 각 문자 위치를 해시맵에 저장하고 중복 시 left를 이동시키는 슬라이딩 윈도우 패턴입니다. 해시 맵으로 문자 위치를 추적해 빠르게 중복 여부를 판단합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(min(n, k))

피드백: 각 문자의 마지막 위치를 저장하고 현재 인덱스와 비교해 왼쪽 포인터를 이동시키는 표준 슬라이딩 윈도우 방식이다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

reverse-linked-list/Chanz82.py
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
        dummy = ListNode()
        dummy = head
        prev = None

        while dummy:
            nextNode = dummy.next
            dummy.next = prev
            prev = dummy
            dummy = nextNode

        return prev
  • 패턴: Linked List, Two Pointers, Reverse Linked List
  • 설명: 주어진 코드는 연결 리스트를 역순으로 뒤집는 문제로, 포인터 두 개를 이용해 노드를 차례로 뒤집는 일반적인 Two Pointers 패턴을 사용합니다. 흐름은 현재 노드와 이전 노드를 유지하며 next를 임시로 보관하고 링크를 역전시키는 방식입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(1)

피드백: 반전 과정에서 prev, nextNode를 이용해 노드의 연결을 뒤집는다. 루프 종료 후 prev가 새 head가 된다.

개선 제안: dummy 변수 할당이 불필요해 보이나 현재 로직은 올바르게 동작한다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

@okyungjin
okyungjin self-requested a review August 8, 2026 04:53

@okyungjin okyungjin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

풀이 잘 봤습니다. 이후에 확인이 어려워서 승인처리해요.
이번 주도 고생하셨습니다! 다음 주도 파이팅하세요 : )

Comment on lines +8 to +9
dummy = ListNode()
dummy = head

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

8라인이 필요할까요? 바로 아래 코드에서 head로 덮어써지네요

@parkhojeong parkhojeong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

수고하셨습니다

dummy = head
prev = None

while dummy:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dummy는 어떤 값이 담기는지 알기가 어려운데요. 의미에 맞는 네이밍을 하시는 건 어떨까요?

parkhojeong
parkhojeong approved these changes Aug 8, 2026
def lengthOfLongestSubstring(self, s: str) -> int:
left = 0
max_len = 0
visited = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

visited는 단순히 방문했던 것만 담는 것처럼 느껴지는데요. 인덱스를 담는다는 걸 나타내는 건 어떨까요?

@parkhojeong
parkhojeong merged commit 93919e8 into DaleStudy:main Aug 9, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Solving to Completed in 리트코드 스터디 8기 Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

3 participants