핵심 자료구조 비교

자료구조 Python Java JavaScript
동적 배열 list (내장)
arr = [1, 2, 3]arr.append(4) **ArrayList**List<Integer> list = new ArrayList<>();list.add(1); Array (내장)
const arr = [1, 2, 3];arr.push(4);
연결 리스트 **collections.deque**from collections import dequedq = deque([1, 2, 3]) **LinkedList**LinkedList<Integer> list = new LinkedList<>();list.add(1); 직접 구현 필요 또는 배열로 대체
스택 list 또는 **deque**stack = []stack.append(1) (push)
stack.pop() Deque<Integer> (ArrayDeque 권장)
Deque<Integer> stack = new ArrayDeque<>();stack.push(1);stack.pop(); **Array**const stack = [];stack.push(1);stack.pop();
큐 **collections.deque**from collections import dequeq = deque()q.append(1) (enqueue)
q.popleft() (dequeue)
Queue<Integer> (LinkedList 권장)
Queue<Integer> q = new LinkedList<>();q.offer(1);q.poll(); **Array**const queue = [];queue.push(1);queue.shift();
덱(양방향 큐) **collections.deque**dq.append(1) (오른쪽)
dq.appendleft(0) (왼쪽)
dq.pop() (오른쪽 제거)
dq.popleft() (왼쪽 제거)
Deque<Integer> (ArrayDeque 권장)
dq.addLast(1);dq.addFirst(0);dq.pollLast();dq.pollFirst(); **Array**arr.push(1); (끝)
arr.unshift(0); (앞)
arr.pop(); (끝 제거)
arr.shift(); (앞 제거)
해시맵 dict (내장)
map = {'key': 'value'}map['key']
또는 collections.defaultdict **HashMap<K, V>**Map<String, Integer> map = new HashMap<>();map.put("key", 1);map.getOrDefault("key", 0); Map (ES6)
const map = new Map();map.set('key', 'value');map.get('key');
또는 Object
해시셋 set (내장)
s = {1, 2, 3}s.add(4)1 in s (True)
**HashSet<T>**Set<Integer> set = new HashSet<>();set.add(1);set.contains(1); Set (ES6)
const set = new Set([1, 2, 3]);set.add(4);set.has(1); (true)
우선순위 큐 (힙) heapq (최소힙)
import heapqheap = []heapq.heappush(heap, 3)heapq.heappop(heap) **PriorityQueue<T>**PriorityQueue<Integer> pq = new PriorityQueue<>();pq.offer(3);pq.poll(); 내장 없음
직접 구현 또는 heap-js 패키지 사용
[📦 NPM]
정렬된 맵 (TreeMap) 내장 없음
sortedcontainers 패키지 (외부 설치)
[📦 PyPI] **TreeMap<K, V>**Map<String, Integer> tm = new TreeMap<>();tm.put("b", 2);tm.put("a", 1);(자동 정렬됨) 내장 없음
직접 구현 필요
정렬된 셋 (TreeSet) 내장 없음
sortedcontainers 패키지 (외부 설치)
[📦 PyPI] **TreeSet<T>**Set<Integer> ts = new TreeSet<>();ts.add(3);ts.add(1);(자동 정렬됨) 내장 없음
직접 구현 필요

유용한 유틸리티 모듈

기능 Python Java JavaScript
빈도수 카운팅 **collections.Counter**c = Counter(['a', 'b', 'a'])c.most_common(1) Map으로 직접 구현
또는 Guava의 Multiset[📦 Guava] Map 또는 Object로 직접 구현
또는 Lodash의 _.countBy[📦 Lodash]
이진 탐색 **bisect**import bisectbisect.bisect_left(arr, x)bisect.insort(arr, x) Arrays.binarySearch()Collections.binarySearch() 직접 구현 필요
또는 Lodash의 _.sortedIndex
순열/조합 **itertools**from itertools import permutations, combinationslist(permutations([1,2,3]))list(combinations([1,2,3], 2)) 직접 재귀로 구현
또는 Apache Commons[📦 Commons] 직접 재귀로 구현
정렬 유틸 sorted(arr, key=lambda x: x)arr.sort(reverse=True) **Arrays.sort(arr)Collections.sort(list, comparator)**list.sort(Comparator.comparing(...)) arr.sort((a, b) => a - b)

📚 종합 레퍼런스

언어 주요 레퍼런스
Python 공식 표준 라이브러리
Java Java Collections Framework
JavaScript MDN - 표준 내장 객체

💡 실무 팁

코딩테스트 준비할 때:

실무 프로젝트할 때: