Skip to content

Conversation

lylaminju
Copy link
Contributor

@lylaminju lylaminju commented Jan 19, 2025

답안 제출 문제

체크 리스트

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

@lylaminju lylaminju requested a review from jungsiroo January 19, 2025 19:09
@lylaminju lylaminju requested a review from a team as a code owner January 19, 2025 19:09
@github-actions github-actions bot added the py label Jan 19, 2025
Comment on lines +17 to +19
while s[right] in chars:
chars.remove(s[left])
left += 1
Copy link
Contributor

@obzva obzva Jan 23, 2025

Choose a reason for hiding this comment

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

while문으로 중복되는 문자를 찾을 때까지 한 문자 한 문자 지우는 로직을 좀 더 단순하게 바꿀 수 있을 것 같아요
저라면 set으로 chars를 관리하는 것 대신에 dictionary로 관리할 것 같습니다
이러면 연산량이 좀 줄어들어요

        length = 0
        left = 0
        lookup = {}

        for right, char in enumerate(s):
            if char in lookup and lookup[char] >= left:
                left = lookup[char] + 1
            lookup[char] = right
            length = max(length, right + 1 - left)

Comment on lines +5 to +6
공간 복잡도: O(m * n)
- dp 테이블을 사용하여 모든 셀에 대한 경로 수를 저장하므로 공간 복잡도는 O(m * n)입니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

O(m)으로 최적화할 수 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

전체 2차원 배열을 유지할 필요 없이, 한 행만 유지하면서 정보를 갱신하면 되겠네요! 피드백 감사합니다 :)

class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        dp = [1] * n

        for row in range(1, m):
            for col in range(1, n):
                dp[col] += dp[col - 1]

        return dp[-1]

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

@obzva obzva left a comment

Choose a reason for hiding this comment

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

Lyla님 안녕하세요 :)
깔끔한 풀이와 설명 덕에 리뷰하기 편했습니다
코멘트를 조금 남겨놓았으니 병합 전에 확인 바랍니다
감사합니다

@lylaminju lylaminju merged commit 2c41acd into DaleStudy:main Jan 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants