📚
Remove Duplicates
Remove Duplicates쉬움 배열 +10pts
Problem
Write a function that removes duplicate values from an array.
Examples
Input:
removeDuplicates([1, 2, 2, 3, 3, 3])Output:
[1, 2, 3]Explanation
이 문제는 **Set 자료구조**를 활용하여 배열에서 중복을 제거하는 방법을 학습합니다. **Set이란?** Set은 중복을 허용하지 않는 값들의 집합입니다. 같은 값을 여러 번 추가해도 하나만 저장됩니다. **Set으로 중복 제거하기** 1. `new Set(arr)` - 배열로 Set 생성 (중복 자동 제거) 2. `[...set]` - Set을 다시 배열로 변환 **[1, 2, 2, 3, 3, 3] 처리 과정** - new Set([1, 2, 2, 3, 3, 3]) → Set {1, 2, 3} - [...Set {1, 2...
View detailed explanation →Key Concepts
Set 자료구조 중복 제거 패턴 스프레드 연산자 삽입 순서 보존
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.