Tap here to switch tabs
Problem
Submissions

Problem: Make Array Non-decreasing or Non-increasing

med
30 min
Try to solve the Make Array Non-decreasing or Non-increasing problem.

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

med
30 min
Try to solve the Make Array Non-decreasing or Non-increasing problem.

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