Tap here to switch tabs
Problem
Submissions

Problem: Minimum Increase to Maximize Special Indices

Minimum Increase to Maximize Special Indices asks you to raise elements in an array so as many values as possible exceed both immediate neighbors, then return the fewest increments needed.

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

Minimum Increase to Maximize Special Indices asks you to raise elements in an array so as many values as possible exceed both immediate neighbors, then return the fewest increments needed.

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