leetcode

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

2178.cpp (360B)


      1 class Solution {
      2   public:
      3     vector<long long> maximumEvenSplit(long long finalSum) const {
      4         if (finalSum % 2) return {};
      5         vector<long long> res;
      6         for (long long crnt = 2; finalSum >= crnt; crnt += 2) {
      7             res.push_back(crnt);
      8             finalSum -= crnt;
      9         }
     10         res.back() += finalSum;
     11         return res;
     12     }
     13 };