915. Partition Array into Disjoint Intervals Medium
1/**
2 * [915] Partition Array into Disjoint Intervals
3 *
4 * Given an integer array nums, partition it into two (contiguous) subarrays left and right so that:
5 *
6 * Every element in left is less than or equal to every element in right.
7 * left and right are non-empty.
8 * left has the smallest possible size.
9 *
10 * Return the length of left after such a partitioning.
11 * Test cases are generated such that partitioning exists.
12 *
13 * Example 1:
14 *
15 * Input: nums = [5,0,3,8,6]
16 * Output: 3
17 * Explanation: left = [5,0,3], right = [8,6]
18 *
19 * Example 2:
20 *
21 * Input: nums = [1,1,1,0,6,12]
22 * Output: 4
23 * Explanation: left = [1,1,1,0], right = [6,12]
24 *
25 *
26 * Constraints:
27 *
28 * 2 <= nums.length <= 10^5
29 * 0 <= nums[i] <= 10^6
30 * There is at least one valid answer for the given input.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/partition-array-into-disjoint-intervals/
36// discuss: https://leetcode.com/problems/partition-array-into-disjoint-intervals/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn partition_disjoint(nums: Vec<i32>) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_915() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.