Tap here to switch tabs
Problem
Submissions

Problem: Smallest Stable Index I

Try to solve the Smallest Stable Index I problem.

Statement

You are given a 00 indexed integer array nums and an integer k.

For each index i (0≤i<0 \leq i < nums.length), the instability score is defined as the maximum value in the subarray from index 00 to i minus the minimum value in the subarray from index i to nums.length −1- 1.

An index i is considered stable if its instability score is less than or equal to k.

Return the smallest stable index i. If no such index exists, return −1-1.

Constraints:

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

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

  • 0≤0 \leq k ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Stable Index I

Try to solve the Smallest Stable Index I problem.

Statement

You are given a 00 indexed integer array nums and an integer k.

For each index i (0≤i<0 \leq i < nums.length), the instability score is defined as the maximum value in the subarray from index 00 to i minus the minimum value in the subarray from index i to nums.length −1- 1.

An index i is considered stable if its instability score is less than or equal to k.

Return the smallest stable index i. If no such index exists, return −1-1.

Constraints:

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

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

  • 0≤0 \leq k ≤109\leq 10^9