Open
Conversation
raejun92
approved these changes
Mar 18, 2026
| const arrLength = nums.length; | ||
| const set = new Set(nums); | ||
|
|
||
| return arrLength !== set.size; |
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) 복잡도 계산
2) 접근 아이디어
Set으로 중복 제거한 뒤의 길이를 비교했다.3) 회고
Set(nums)로 바로 길이를 비교하는 방식이라 구현은 빠르고 간단했다.다른 사람 풀이:
다른 사람 풀이 핵심: 값을 하나씩 보면서 이미 본 값인지 바로 확인하고, 중복이 발견되는 순간 즉시 종료하는 방식이었다.
내 생각:
Set으로 값을 하나씩 저장하고 같은 값이 나오면 바로 boolean 값을 반환하는 방식이 더 빠를 수 있겠다고 느꼈다.2. Roman to Integer
1) 복잡도 계산
2) 접근 아이디어
3) 회고
현재 문자와 다음 문자를 비교해서 더할지 뺄지를 결정하는 흐름으로 정리하니 문제 구조가 훨씬 잘 보였다.
처음엔
if문을 길게 써서 문자마다 값을 바로 반환하는 방식도 생각했다.이런 식으로 미리 early return을 줘도 괜찮을 것 같긴 한데, 이번에는 객체로 매핑해 두는 쪽이 반복 계산할 때 더 깔끔하게 느껴졌다.