Tap here to switch tabs
Problem
Submissions

Problem: Count Non-Decreasing Subarrays After K Operations

Try to solve the Count Non-Decreasing Subarrays After K Operations problem.

Statement

You are given an integer array nums and an integer k.

In a single operation, you can choose any element in nums and increment its value by 11.

Return the total number of contiguous subarrays of nums that can be made non decreasing by performing at most k operations.

Note: A subarray is non decreasing if each element is greater than or equal to the element immediately before it.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Non-Decreasing Subarrays After K Operations

Try to solve the Count Non-Decreasing Subarrays After K Operations problem.

Statement

You are given an integer array nums and an integer k.

In a single operation, you can choose any element in nums and increment its value by 11.

Return the total number of contiguous subarrays of nums that can be made non decreasing by performing at most k operations.

Note: A subarray is non decreasing if each element is greater than or equal to the element immediately before it.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

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