Tap here to switch tabs
Problem
Submissions

Problem: Count Partitions With Max-Min Difference at Most K

med
30 min
Try to solve the Count Partitions With Max-Min Difference at Most K problem.

Statement

Given an integer array nums and an integer k, determine the total number of partitions of nums into contiguous non empty subarrays such that for every subarray, the difference between its maximum element and its minimum element is at most k.

Constraints:

  • 2≤2 \leq nums.length ≤5imes104\leq 5 imes 10^4

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Partitions With Max-Min Difference at Most K

med
30 min
Try to solve the Count Partitions With Max-Min Difference at Most K problem.

Statement

Given an integer array nums and an integer k, determine the total number of partitions of nums into contiguous non empty subarrays such that for every subarray, the difference between its maximum element and its minimum element is at most k.

Constraints:

  • 2≤2 \leq nums.length ≤5imes104\leq 5 imes 10^4

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

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