1 2 3 4 5 6 7 8 9 10 11 12 13
| class Solution { public: vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) { vector<int> diff(n); for (auto &b : bookings) { int first = b[0], last = b[1], seats = b[2]; diff[first - 1] += seats; if (last < n) diff[last] -= seats; } for (int i = 1; i < n; ++i) diff[i] += diff[i - 1]; return diff; } };
|