3388. Count Beautiful Splits in an Array Medium

@problem@discussion
#Array#Dynamic Programming



1/**
2 * [3388] Count Beautiful Splits in an Array
3 *
4 * You are given an array nums.
5 * A split of an array nums is beautiful if:
6 * <ol>
7 * 	The array nums is split into three <span data-keyword="subarray-nonempty">subarrays</span>: nums1, nums2, and nums3, such that nums can be formed by concatenating nums1, nums2, and nums3 in that order.
8 * 	The subarray nums1 is a <span data-keyword="array-prefix">prefix</span> of nums2 OR nums2 is a <span data-keyword="array-prefix">prefix</span> of nums3.
9 * </ol>
10 * Return the number of ways you can make this split.
11 *  
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">nums = [1,1,2,1]</span>
15 * Output: <span class="example-io">2</span>
16 * Explanation:
17 * The beautiful splits are:
18 * <ol>
19 * 	A split with nums1 = [1], nums2 = [1,2], nums3 = [1].
20 * 	A split with nums1 = [1], nums2 = [1], nums3 = [2,1].
21 * </ol>
22 * </div>
23 * <strong class="example">Example 2:
24 * <div class="example-block">
25 * Input: <span class="example-io">nums = [1,2,3,4]</span>
26 * Output: <span class="example-io">0</span>
27 * Explanation:
28 * There are 0 beautiful splits.
29 * </div>
30 *  
31 * Constraints:
32 * 
33 * 	1 <= nums.length <= 5000
34 * 	<font face="monospace">0 <= nums[i] <= 50</font>
35 * 
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/count-beautiful-splits-in-an-array/
40// discuss: https://leetcode.com/problems/count-beautiful-splits-in-an-array/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45    pub fn beautiful_splits(nums: Vec<i32>) -> i32 {
46        0
47    }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54    use super::*;
55
56    #[test]
57    fn test_3388() {
58    }
59}
60


Back
© 2025 bowen.ge All Rights Reserved.