Conversation
raejun92
approved these changes
Mar 20, 2026
Collaborator
raejun92
left a comment
There was a problem hiding this comment.
고생하셨습니다. 이번엔 그렇게 어렵지 않아서 금방 푸셧네요!
Collaborator
There was a problem hiding this comment.
슬기님 풀이와 같군요!
Set에 모든 배열을 넣지않고 하나씩 확인하면서 얼리 리턴을 하면 조금 더 빠를 수 있을 것 같아요
doitchuu
approved these changes
Mar 20, 2026
Comment on lines
+15
to
+16
| const current = map[s[i]]; | ||
| const next = map[s[i + 1]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이렇게 풀었어요
1. Contains Duplicate
1) 복잡도 계산
시간 복잡도: O(n)
공간 복잡도: O(n)
2) 접근 아이디어
중복이란 키워드를 보고 바로 Set이 떠올랐고, 원본 길이와 Set 길이를 비교해서 다르면 중복이 있다는 것을 알 수 있다.
3) 회고
다른 방법으로는 배열을 정렬한 뒤 인접한 원소끼리 비교하는 방법이 있을 것 같다.
하지만 이 방법은 시간 복잡도가 O(n log n)이 되므로 Set을 이용하는 방법이 더 효율적이다. (그러나 공간복잡도는 이 방법이 더 효율적일듯 o(log n)정도.)
2. Roman to Integer
1) 복잡도 계산
시간 복잡도: O(n)
공간 복잡도: O(1)
2) 접근 아이디어
로마 숫자는 기본적으로 왼쪽에서 오른쪽으로 더하면 되지만, 현재 문자가 다음 문자보다 작은 경우는 빼주는 규칙이 있다.
따라서 각 문자를 순회하면서 다음 문자와 비교해 작으면 빼고, 아니면 더하는 방식으로 구현했다.
3) 회고
처음에는 단순히 문자마다 값을 더하는 문제라고 생각했는데, 실제로는 다음 문자와의 관계를 봐야 한다는 점이 중요했다.
예외 케이스를 따로 외워서 처리하기보다, 현재 값과 다음 값을 비교하는 규칙으로 풀 수 있다는 점이 인상적이었다.