Skip to content

Commit 470bfea

Browse files
committed
programmers.co.kr 코딩테스트 연습 힙(Heap) 디스크 컨트롤러
문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/42627 파이썬 소스: https://bit.ly/4bNyGhw
1 parent 86a0d60 commit 470bfea

File tree

2 files changed

+1
-16
lines changed
  • leetcode.com 435. Non-overlapping Intervals
  • programmers.co.kr 코딩테스트 연습 힙(Heap) 디스크 컨트롤러

2 files changed

+1
-16
lines changed

leetcode.com 435. Non-overlapping Intervals/main.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from functools import cmp_to_key
21
from typing import List
32

43
class Solution:

programmers.co.kr 코딩테스트 연습 힙(Heap) 디스크 컨트롤러/main.py

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
from typing import List
22
import heapq
3-
from functools import cmp_to_key
4-
5-
def my_sort(a, b):
6-
if a[0] < b[0]:
7-
return -1
8-
elif a[0] > b[0]:
9-
return 1
10-
else: # a[0] == b[0]
11-
if a[1] < b[1]:
12-
return -1
13-
elif a[1] > b[1]:
14-
return 1
15-
else: # a[1] == b[1]
16-
return 0
173

184
def solution(jobs: List):
195
current_time = 0
206
answer = 0
217
count = len(jobs)
22-
jobs = sorted(jobs, key=cmp_to_key(my_sort))
8+
jobs.sort()
239
heap = []
2410

2511
while len(jobs) > 0 or len(heap) > 0:

0 commit comments

Comments
 (0)