leetcode

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

2640.cpp (408B)


      1 class Solution {
      2   public:
      3     vector<long long> findPrefixScore(const vector<int> &nums) {
      4         ios_base::sync_with_stdio(false);
      5         cin.tie(NULL);
      6 
      7         vector<long long> res(nums.size());
      8         for (long long i = 0, acc = 0, maxi = 0; i < nums.size(); i++) {
      9             maxi = max(maxi, (long long)nums[i]);
     10             res[i] = acc += nums[i] + maxi;
     11         }
     12         return res;
     13     }
     14 };