-
Notifications
You must be signed in to change notification settings - Fork 125
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
[SunaDu] Week 7 #935
[SunaDu] Week 7 #935
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
더미 노드를 하나 둬서 1루프로 풀이하셨군요 👍
리뷰와는 별개로 PR 제목이 잘못된 것 같습니다 😭
넵 리뷰 감사합니다🥹 수정했습니다 |
def lengthOfLongestSubstring(self, s: str) -> int: | ||
max_count = 0 | ||
start = 0 | ||
substrings = set() # SC: O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
부분문자열에서 각 문자는 1회만 등장할 수 있다는 조건때문에 Set을 선택하셨군요. 👍
문자의 범위가 명확하게 정의되어 있다면 (e.g ASCII) 배열을 사용할 수도 있을 것 같아요!
아래 문제도 추가적으로 풀어보시면 sliding window 패턴을 익히시는데 도움이 될 것 같습니다
https://leetcode.com/problems/substring-with-concatenation-of-all-words
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASCII코드 배열로 문자의 마지막 위치를 확인하는 방법이 있군요! 감사합니다
char_index = [-1] * 128 # SC: O(128) | |
for end in range(len(s)): # TC: O(n) | |
if char_index[ord(s[end])] >= start: | |
start = char_index[ord(s[end])] + 1 | |
char_index[ord(s[end])] = end | |
max_count = max(max_count, end - start + 1) |
추천해 주신 문제도 풀어보고 통과하면 댓글 달겠습니다😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekgns33
오래걸렸지만 추천해주신 문제 풀이해봤습니다🥹
permutation 경우를 변수에 저장했다가는 SC가 n!이 되는 점이 인상 깊었어요
슬라이딩 윈도우로 탐색할 때 어떤 데이터를 추적하는지 관련된 문제를 풀면서 예시를 많이 보면 좋겠다고 생각했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요!
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.