Partition Array into Disjoint Intervals
Given an array A
, partition it into two (contiguous) subarrays left
and right
so that:
Every element in
left
is less than or equal to every element inright
.left
andright
are non-empty.left
has the smallest possible size.
Return the length of left
after such a partitioning. It is guaranteed that such a partitioning exists.
Example 1:
Example 2:
Note:
2 <= A.length <= 30000
0 <= A[i] <= 10^6
It is guaranteed there is at least one way to partition
A
as described.
Last updated