Available question text
Count the number of ways to split an array into one or more contiguous segments so that in every segment the difference between its maximum and minimum is at most k, returning the result modulo 1e9+7. With n up to 5·10^4 this requires an O(n)–O(n log n) approach (DP with a sliding-window/monotonic structure to track valid segment boundaries).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3578. Count Partitions With Max-Min Difference at Most K
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source