Notice
Recent Posts
Recent Comments
Link
목록heapity (1)
나의 개발일지
문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42626 heapq 모듈 사용 heapq는 이진 트리 기반의 최소 힙 자료구조를 제공 최소 힙으로 항상 오름차순 정렬되어 있다. 정렬된 상태를 유지해야 할 때 계속 정렬할 필요가 없어 속도가 빠르다. heapity() : 리스트를 heap으로 변환, O(N) heappush() : heap에 원소 추가, O(log(n)) heappop() : heap에서 가장 작은(0번 인덱스) 원소 삭제, O(log(n)) from heapq import heapify, heappush, heappop def solution(scoville, K): answer = 0 heapify(scoville) # ..
프로그래머스
2023. 7. 9. 12:10