leetcode

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

1099.cpp (285B)


      1 class Solution {
      2   public:
      3     vector<int> replaceElements(vector<int> &arr) {
      4         int maxi = -1;
      5         for (int i = arr.size() - 1; i >= 0; i--) {
      6             int tmp = arr[i];
      7             arr[i] = maxi;
      8             maxi = max(maxi, tmp);
      9         }
     10         return arr;
     11     }
     12 };