Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Make Array Non Decreasing

Minimum Operations to Make Array Non Decreasing lets you increase contiguous subarrays by positive amounts. Return the least total of operation values needed to make the array nondecreasing.

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

Minimum Operations to Make Array Non Decreasing lets you increase contiguous subarrays by positive amounts. Return the least total of operation values needed to make the array nondecreasing.

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