3420. Count Non-Decreasing Subarrays After K Operations
You are given an array
nums
ofn
integers and an integerk
.For each subarray of
nums
, you can apply up tok
operations on it. In each operation, you increment any element of the subarray by 1.Note that each subarray is considered independently, meaning changes made to one subarray do not persist to another.
Return the number of subarrays that you can make non-decreasing after performing at most
k
operations.An array is said to be non-decreasing if each element is greater than or equal to its previous element, if it exists.
c++
1 | class Solution { |