3046. Split the Array Easy
1/**
2 * [3046] Split the Array
3 *
4 * You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:
5 *
6 * nums1.length == nums2.length == nums.length / 2.
7 * nums1 should contain distinct elements.
8 * nums2 should also contain distinct elements.
9 *
10 * Return true if it is possible to split the array, and false otherwise.
11 *
12 * <strong class="example">Example 1:
13 *
14 * Input: nums = [1,1,2,2,3,4]
15 * Output: true
16 * Explanation: One of the possible ways to split nums is nums1 = [1,2,3] and nums2 = [1,2,4].
17 *
18 * <strong class="example">Example 2:
19 *
20 * Input: nums = [1,1,1,1]
21 * Output: false
22 * Explanation: The only possible way to split nums is nums1 = [1,1] and nums2 = [1,1]. Both nums1 and nums2 do not contain distinct elements. Therefore, we return false.
23 *
24 *
25 * Constraints:
26 *
27 * 1 <= nums.length <= 100
28 * nums.length % 2 == 0
29 * 1 <= nums[i] <= 100
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/split-the-array/
35// discuss: https://leetcode.com/problems/split-the-array/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn is_possible_to_split(nums: Vec<i32>) -> bool {
41 false
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_3046() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.