Leetcode 1184 Solution
This article provides solution to leetcode question 1184 (car-pooling)
Access this page by simply typing in "lcs 1184" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/car-pooling
Solution
class Solution:
def carPooling(self, trips: List[List[int]], capacity: int) -> bool:
events = []
for num, src, dst in trips:
events.append((src, num))
events.append((dst, -num))
events.sort()
curr = 0
for loc, cnt in events:
curr += cnt
if curr > capacity:
return False
return True