leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2136.cpp (508B)


0 class Solution {
1 public:
2 int earliestFullBloom(const vector<int> &plantTime, const vector<int> &growTime) const {
3 const int n = size(plantTime);
4 static int idxs[100001];
6 iota(idxs, idxs + n, 0);
7 sort(idxs, idxs + n, [&](int a, int b) { return growTime[a] > growTime[b]; });
9 int res = 0, acc = 0;
10 for (const int i : span(idxs, n)) {
11 acc += plantTime[i];
12 res = max(res, acc + growTime[i]);
13 }
15 return res;
16 }
17 };