Tap here to switch tabs
Problem
Submissions

Problem: Minimum Increase to Maximize Special Indices

Try to solve the Minimum Increase to Maximize Special Indices problem.

Statement

You are given an integer array nums of length n.

An index i (1≤1 \leq i ≤\leq n −2- 2) is considered special if nums[i] > nums[i - 1] and nums[i] > nums[i + 1].

In a single operation, you can select any index and increase nums[i] by 11.

Return the minimum number of operations needed to achieve the maximum possible number of special indices.

Constraints:

  • 3≤3 \leq n ≤105\leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Increase to Maximize Special Indices

Try to solve the Minimum Increase to Maximize Special Indices problem.

Statement

You are given an integer array nums of length n.

An index i (1≤1 \leq i ≤\leq n −2- 2) is considered special if nums[i] > nums[i - 1] and nums[i] > nums[i + 1].

In a single operation, you can select any index and increase nums[i] by 11.

Return the minimum number of operations needed to achieve the maximum possible number of special indices.

Constraints:

  • 3≤3 \leq n ≤105\leq 10^5

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