题目
【代码】
使用差分数组的思想进行解题
执行用时:104 ms, 在所有 Python3 提交中击败了73.73% 的用户
内存消耗:25.4 MB, 在所有 Python3 提交中击败了25.56% 的用户
通过测试用例:63 / 63
class Solution:
def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]:
ans=[0]*(n+1)
for first,last,seats in bookings:
ans[first-1]+=seats
ans[last]-=seats
for i in range(1,n+1):
ans[i]+=ans[i-1]
return ans[:n]