Skip to content

Commit aeb5343

Browse files
committed
update
1 parent 8674f5f commit aeb5343

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Sliding window/3. Longest Substring Without Repeating Characters.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def carPooling(self, trips: List[List[int]], capacity: int) -> bool:
3+
orders=[]
4+
for p, st, en in trips:
5+
orders.append((st,p))
6+
orders.append((en,-p))
7+
8+
orders.sort()
9+
p=0
10+
for item in orders:
11+
p += item[1]
12+
if p > capacity:
13+
return False
14+
15+
return True
16+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class MyCalendarTwo:
2+
3+
def __init__(self):
4+
self.orders=[]
5+
6+
7+
8+
def book(self, start: int, end: int) -> bool:
9+
orders=self.orders
10+
bisect.insort(orders,(start,1))
11+
bisect.insort(orders,(end,-1))
12+
13+
limit=3
14+
count=0
15+
for item in orders:
16+
count+=item[1]
17+
if count ==limit:
18+
orders.pop(bisect_left(orders, (start,1)))
19+
orders.pop(bisect_left(orders, (end,-1)))
20+
21+
return False
22+
return True

0 commit comments

Comments
 (0)