java.lang.Object
g0901_1000.s0915_partition_array_into_disjoint_intervals.Solution

public class Solution extends Object
915 - Partition Array into Disjoint Intervals.<p>Medium</p> <p>Given an integer array <code>nums</code>, partition it into two (contiguous) subarrays <code>left</code> and <code>right</code> so that:</p> <ul> <li>Every element in <code>left</code> is less than or equal to every element in <code>right</code>.</li> <li><code>left</code> and <code>right</code> are non-empty.</li> <li><code>left</code> has the smallest possible size.</li> </ul> <p>Return <em>the length of</em> <code>left</code> <em>after such a partitioning</em>.</p> <p>Test cases are generated such that partitioning exists.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [5,0,3,8,6]</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> left = [5,0,3], right = [8,6]</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,1,1,0,6,12]</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> left = [1,1,1,0], right = [6,12]</p> <p><strong>Constraints:</strong></p> <ul> <li><code>2 <= nums.length <= 10<sup>5</sup></code></li> <li><code>0 <= nums[i] <= 10<sup>6</sup></code></li> <li>There is at least one valid answer for the given input.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • partitionDisjoint

      public int partitionDisjoint(int[] nums)