Commit 470bfea 1 parent 86a0d60 commit 470bfea Copy full SHA for 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 Original file line number Diff line number Diff line change 1
- from functools import cmp_to_key
2
1
from typing import List
3
2
4
3
class Solution :
Original file line number Diff line number Diff line change 1
1
from typing import List
2
2
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
17
3
18
4
def solution (jobs : List ):
19
5
current_time = 0
20
6
answer = 0
21
7
count = len (jobs )
22
- jobs = sorted ( jobs , key = cmp_to_key ( my_sort ) )
8
+ jobs . sort ( )
23
9
heap = []
24
10
25
11
while len (jobs ) > 0 or len (heap ) > 0 :
You can’t perform that action at this time.
0 commit comments