Tap here to switch tabs
Problem
Submissions

Problem: Make Array Non-decreasing or Non-increasing

Make Array Non-decreasing or Non-increasing asks you to adjust an integer array by incrementing or decrementing elements, then return the fewest operations needed for either ordering.

Statement

Given an integer array nums, you can perform an operation where you choose an index i and either increment or decrement nums[i] by 11.

Return the minimum number of operations required to make nums either non decreasing or non increasing.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Make Array Non-decreasing or Non-increasing

Make Array Non-decreasing or Non-increasing asks you to adjust an integer array by incrementing or decrementing elements, then return the fewest operations needed for either ordering.

Statement

Given an integer array nums, you can perform an operation where you choose an index i and either increment or decrement nums[i] by 11.

Return the minimum number of operations required to make nums either non decreasing or non increasing.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤1000\leq 1000