-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
1109.cpp
24 lines (19 loc) · 818 Bytes
/
1109.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
__________________________________________________________________________________________________
class Solution {
public:
vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) {
vector<int> change(n + 1, 0);
for (vector<int> &booking : bookings) {
booking[0]--;
booking[1]--;
change[booking[0]] += booking[2];
change[booking[1] + 1] -= booking[2];
}
vector<int> seats(n, 0);
for (int i = 0; i < n; i++)
seats[i] = (i == 0 ? 0 : seats[i - 1]) + change[i];
return seats;
}
};
__________________________________________________________________________________________________
__________________________________________________________________________________________________