Corporate Flight Bookings LeetCode solution in C++

1
class Solution {
2
public:
3
vector<int> corpFlightBookings(vector<vector<int>> &bookings, int n) {
4
vector<int> arr(n);
5
for (const auto &b : bookings) {
6
int start = b[0] - 1, end = b[1], seats = b[2];
7
arr[start] += seats;
8
if (end < n) {
9
arr[end] -= seats;
10
}
11
}
12
partial_sum(begin(arr), end(arr), begin(arr));
13
return arr;
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0