Skip to content

Commit 6ab399e

Browse files
authored
Create corporate-flight-bookings.py
1 parent 4d5a5f6 commit 6ab399e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Python/corporate-flight-bookings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def corpFlightBookings(self, bookings, n):
6+
"""
7+
:type bookings: List[List[int]]
8+
:type n: int
9+
:rtype: List[int]
10+
"""
11+
result = [0]*(n+1)
12+
for i, j, k in bookings:
13+
result[i-1] += k
14+
result[j] -= k
15+
for i in xrange(1, len(result)):
16+
result[i] += result[i-1]
17+
result.pop()
18+
return result

0 commit comments

Comments
 (0)