Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Non Decreasing

Try to solve the Minimum Operations to Make Array Non Decreasing problem.

Statement

You are given an integer array nums of length n.

In one operation, you can select a contiguous subarray of nums and a positive integer x, then increase each element in the selected subarray by x.

Return the minimum possible sum of all chosen values of x required to make nums non decreasing.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Non Decreasing

Try to solve the Minimum Operations to Make Array Non Decreasing problem.

Statement

You are given an integer array nums of length n.

In one operation, you can select a contiguous subarray of nums and a positive integer x, then increase each element in the selected subarray by x.

Return the minimum possible sum of all chosen values of x required to make nums non decreasing.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9