DatasetRepo's picture
Upload folder using huggingface_hub (#1)
24e07f8 verified
{
"id": 2916,
"name": "check_if_it_is_possible_to_split_array",
"difficulty": "Medium",
"link": "https://leetcode.com/problems/check-if-it-is-possible-to-split-array/",
"date": "1690675200000",
"task_description": "You are given an array `nums` of length `n` and an integer `m`. You need to determine if it is possible to split the array into `n` arrays of size 1 by performing a series of steps. An array is called **good** if: The length of the array is **one**, or The sum of the elements of the array is **greater than or equal** to `m`. In each step, you can select an existing array (which may be the result of previous steps) with a length of **at least two** and split it into **two **arrays, if both resulting arrays are good. Return true if you can split the given array into `n` arrays, otherwise return false. **Example 1:** **Input:** nums = [2, 2, 1], m = 4 **Output:** true **Explanation:** Split `[2, 2, 1]` to `[2, 2]` and `[1]`. The array `[1]` has a length of one, and the array `[2, 2]` has the sum of its elements equal to `4 >= m`, so both are good arrays. Split `[2, 2]` to `[2]` and `[2]`. both arrays have the length of one, so both are good arrays. **Example 2:** **Input:** nums = [2, 1, 3], m = 5 **Output:** false **Explanation:** The first move has to be either of the following: Split `[2, 1, 3]` to `[2, 1]` and `[3]`. The array `[2, 1]` has neither length of one nor sum of elements greater than or equal to `m`. Split `[2, 1, 3]` to `[2]` and `[1, 3]`. The array `[1, 3]` has neither length of one nor sum of elements greater than or equal to `m`. So as both moves are invalid (they do not divide the array into two good arrays), we are unable to split `nums` into `n` arrays of size 1. **Example 3:** **Input:** nums = [2, 3, 3, 2, 3], m = 6 **Output:** true **Explanation:** Split `[2, 3, 3, 2, 3]` to `[2]` and `[3, 3, 2, 3]`. Split `[3, 3, 2, 3]` to `[3, 3, 2]` and `[3]`. Split `[3, 3, 2]` to `[3, 3]` and `[2]`. Split `[3, 3]` to `[3]` and `[3]`. **Constraints:** `1 <= n == nums.length <= 100` `1 <= nums[i] <= 100` `1 <= m <= 200`",
"public_test_cases": [
{
"label": "Example 1",
"input": "nums = [2, 2, 1], m = 4",
"output": "true "
},
{
"label": "Example 2",
"input": "nums = [2, 1, 3], m = 5",
"output": "false "
},
{
"label": "Example 3",
"input": "nums = [2, 3, 3, 2, 3], m = 6",
"output": "true "
}
],
"private_test_cases": [
{
"input": [
[
18,
69,
96,
19,
19,
24,
75,
93
],
37
],
"output": true
},
{
"input": [
[
71,
4,
31,
26,
15,
30,
31,
23,
100,
84,
50,
17,
61,
40,
49,
52,
84,
86,
15,
37,
81,
92,
80,
30,
78,
74,
99,
60,
9,
27,
41,
9,
71,
67,
89,
74,
24,
3,
95,
49,
35,
76,
19,
48,
15,
40,
3,
27,
17,
26,
83,
52,
63,
19,
70,
22,
84,
97,
38,
4,
68,
60,
30,
68,
64,
56
],
107
],
"output": true
},
{
"input": [
[
87,
25,
44,
89,
7,
51,
1,
82,
2,
57,
2,
75,
76,
55,
50,
51,
8,
42,
93,
25,
69,
86,
36,
50,
81,
84,
43,
65,
70,
9,
48,
82,
91,
32,
8,
59,
21,
43,
31,
44,
39,
48,
71,
53,
34,
1,
49,
65,
25,
36,
50,
57,
16,
65,
43,
100,
1,
8,
27,
58,
53
],
122
],
"output": true
},
{
"input": [
[
67,
12,
92,
44,
8,
80,
61,
28,
50,
78,
35,
80,
43,
28,
8,
53,
81,
35,
21,
79,
30,
69,
54,
77,
47,
12,
15,
22,
80,
93,
83,
91,
95,
13,
10,
25,
86,
43,
97,
20,
27,
40,
10,
38,
11,
57,
15,
44,
64,
69,
56,
98,
94,
2,
31,
61,
27,
97,
76,
36,
56,
50,
64,
75,
57,
100,
78,
82,
56,
6,
15,
66,
8,
13,
70,
68,
50,
82,
4,
29,
14,
87,
27,
68,
69,
58,
45,
30,
35,
18
],
187
],
"output": true
},
{
"input": [
[
64,
44,
32,
43,
20,
52,
35,
93,
3,
33,
80,
70,
16,
62,
37,
89,
58,
27,
18,
5,
18,
66,
6,
49,
21,
62,
21,
16,
36,
50,
16,
50,
81,
97,
100,
5,
26,
53,
39,
28,
70,
82,
25,
81,
20,
35,
83,
54,
84,
31,
14,
65,
31,
19,
91,
1,
100,
69,
67,
78,
93,
42,
63,
71,
83,
16,
58,
66,
32,
95,
71,
59,
18,
87,
8,
14,
49,
93,
41,
45,
47,
31,
47,
69,
28,
66,
82,
94,
85,
74,
32,
21,
11,
38,
3,
30,
85,
72
],
130
],
"output": true
},
{
"input": [
[
50,
47,
14,
22,
1,
63,
74,
56,
25,
90,
74,
37,
88,
68,
88,
8,
41,
14,
4,
100,
35,
49
],
152
],
"output": true
},
{
"input": [
[
25,
40,
72,
94,
35,
73,
22,
4,
89,
42,
21,
98,
72,
55,
82,
71,
62,
21,
2,
99,
58,
36,
41,
99,
15,
61,
57,
94,
56,
25,
35,
30,
19,
68,
18,
14,
61,
40,
23,
52,
31,
48,
14,
35,
91,
62,
25,
21,
77,
96,
57,
69,
80,
27,
67,
23,
9,
38,
38,
86,
94,
16,
14,
64,
48,
89,
19,
21,
91,
24,
19,
58,
73,
76,
60,
60,
79,
35,
20,
67,
67
],
186
],
"output": false
},
{
"input": [
[
48,
81,
54,
60,
65,
99,
90,
22,
7,
80,
41,
49
],
83
],
"output": true
},
{
"input": [
[
47,
28,
38,
52,
96,
31,
17,
56,
47,
75,
75,
60,
70,
31,
53,
25,
64,
51,
33,
80,
79,
10,
10
],
192
],
"output": false
},
{
"input": [
[
92,
17,
34,
46,
6,
27,
60,
62,
77,
77,
36,
12,
49,
73,
15,
45,
26,
62,
11,
11,
1,
49,
24,
78,
29,
15,
40,
95,
73,
77,
11
],
187
],
"output": false
}
],
"haskell_template": "canSplitArray :: [Int] -> Int -> Bool\ncanSplitArray nums m ",
"ocaml_template": "let canSplitArray (nums: int list) (m: int) : bool = ",
"scala_template": "def canSplitArray(nums: List[Int],m: Int): Boolean = { \n \n}",
"java_template": "public static boolean canSplitArray(List<Integer> nums, int m) {\n\n}",
"python_template": "class Solution(object):\n def canSplitArray(self, nums, m):\n \"\"\"\n :type nums: List[int]\n :type m: int\n :rtype: bool\n \"\"\"\n "
}