Earliest Possible Day of Full Bloom LeetCode solution in C++
1class Solution {2public:3int earliestFullBloom(vector<int> &plantTime, vector<int> &growTime) {4int n = plantTime.size();5// growTime larger first6vector<pair<int, int>> times(n);7for (int i = 0; i < n; i++) {8times[i].first = -growTime[i];9times[i].second = plantTime[i];10}11sort(times.begin(), times.end());12int tot = 0;13int cur = 0;14for (int i = 0; i < n; i++) {15tot = max(tot, cur + times[i].second - times[i].first);16cur += times[i].second;17}18return tot;19}20};