1526.cpp (263B)
1 class Solution { 2 public: 3 int minNumberOperations(const vector<int> &target) const { 4 int res = target[0]; 5 6 for (int i = 1; i < size(target); i++) { 7 res += max(target[i] - target[i - 1], 0); 8 } 9 10 return res; 11 } 12 };