일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- lv4
- Stack
- time complexity
- 조합
- LeetCode
- itertools
- sql
- Queue
- Growth hacking
- 파이썬
- level4
- collections
- 코테
- coding
- mysql
- import re
- programmers
- join
- Level2
- AARRR
- 코딩테스트
- coding test
- python
- tableau
- 프로그래머스
- 코딩
- cte
- 완전탐색
- lambda
- counter
Archives
- Today
- Total
목록Priority Queue (1)
ror_coding
[Python] Heap (Priority Queue)
heapq 는 "우선순위 큐(Priority Queue)"를 구현하는 데 유용함. 우선순위 큐 ) 항목의 우선순위에 따라 처리되는 데이터 구조.따라서 가장 작은(또는 가장 큰) 항목을 우선적으로 처리하는데 사용됨.ex) 작업 스케줄링, 다익스트라 알고리즘(Dijkstra's algorithm) 등. import heapqheapq.heapify(l1) # => 자동 정렬된 list(heap)가 됨. # O(n)# 1. 삽입/추출heapq.heappush(lst, 0) # O(log n)= heapq.heappop(lst) # O(log n)# 2. 삽입+추출= heapq.heappushpop(lst, 0) # O(log n) # 삽입 후, 바로 최솟값 추출.= heapq.heapreplace(lst, i..
Coding Test/Python
2024. 12. 8. 15:36