Advertisement
nikunjsoni

1526

May 27th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int minNumberOperations(vector<int>& target) {
  4.         int ans = target[0];
  5.         for(int i=1; i<target.size(); i++)
  6.             ans += max(0, target[i]-target[i-1]);
  7.         return ans;
  8.     }
  9. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement