Description
Submission
class Solution { public: vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) { int m = bookings.size(); vector<int> diff(n + 2, 0); for(auto& book: bookings) { diff[book[0]] += book[2]; diff[book[1]+1] -= book[2]; } vector<int> rets; int total = 0; for(int i = 1; i <= n; ++i) { total += diff[i]; rets.push_back(total); } return rets; } }; // diff[i] = rets[i] = rets[i-1];