Skip to content

Practice Partition Array into Disjoint Intervals

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#915
LeetCode Problem

Partition Array into Disjoint Intervals

Problem Statement

Split nums into a nonempty prefix left and nonempty suffix right such that every left value is at most every right value. Choose the smallest possible left length and return it. At least one valid split is guaranteed.

Source: Partition Array into Disjoint Intervals on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [5,0,3,8,6]
Output
3

# Example 2

Input
nums = [1,1,1,0,6,12]
Output
4

Constraints

2 <= nums.length <= 10^5
0 <= nums[i] <= 10^6
There is at least one valid answer for the given input.

Related LeetCode Problems

Practice more problems similar to Partition Array into Disjoint Intervals.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.