You are given an integer array
numsof lengthnand an integerk.For each index
i, define its instability score asmax(nums[0..i]) - min(nums[i..n - 1]).In other words:
max(nums[0..i])is the largest value among the elements from index 0 to indexi.min(nums[i..n - 1])is the smallest value among the elements from indexito indexn - 1.An index
iis called stable if its instability score is less than or equal tok.Return the smallest stable index. If no such index exists, return -1.
1 | class Solution { |