#3420

Count Non-Decreasing Subarrays After K Operations

international master · 2130 · lc hard +32 · 23.8% accepted · 84 likes · top 3%

Description

You are given an array nums of n integers and an integer k.

For each subarray of nums you may apply at most k operations, where each operation increments any element by 1. Subarrays are treated independently.

Return the count of subarrays that can be made non-decreasing using at most k operations.

An array is non-decreasing if each element is at least as large as its predecessor.

Code

1
2
3