DatasetRepo commited on
Commit
cda9306
·
verified ·
1 Parent(s): 99c27a8

98518f6232b8c97162c9e2cf01e2d99952b5e61ffddb28be94c91646ab5c88f1

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +5 -0
  2. distribute_candies_among_children_ii/meta.json +97 -0
  3. distribute_candies_among_children_ii/ocaml_tests/main.ml +50 -0
  4. distribute_candies_among_children_ii/scala_tests/MySuite.scala +44 -0
  5. distribute_elements_into_two_arrays_i/haskell_tests/Main.hs +41 -0
  6. distribute_elements_into_two_arrays_i/java_tests/Main.java +20 -0
  7. distribute_elements_into_two_arrays_i/meta.json +361 -0
  8. distribute_elements_into_two_arrays_i/ocaml_tests/main.ml +42 -0
  9. distribute_elements_into_two_arrays_i/scala_tests/MySuite.scala +32 -0
  10. distribute_elements_into_two_arrays_ii/haskell_tests/Main.hs +3 -0
  11. distribute_elements_into_two_arrays_ii/java_tests/Main.java +24 -0
  12. distribute_elements_into_two_arrays_ii/meta.json +3 -0
  13. distribute_elements_into_two_arrays_ii/ocaml_tests/main.ml +0 -0
  14. distribute_elements_into_two_arrays_ii/scala_tests/MySuite.scala +0 -0
  15. distribute_money_to_maximum_children/.DS_Store +0 -0
  16. distribute_money_to_maximum_children/haskell_tests/Main.hs +24 -0
  17. distribute_money_to_maximum_children/java_tests/Main.java +21 -0
  18. distribute_money_to_maximum_children/meta.json +97 -0
  19. distribute_money_to_maximum_children/ocaml_tests/main.ml +26 -0
  20. distribute_money_to_maximum_children/scala_tests/MySuite.scala +12 -0
  21. divide_a_string_into_groups_of_size_k/.DS_Store +0 -0
  22. divide_a_string_into_groups_of_size_k/haskell_tests/Main.hs +24 -0
  23. divide_a_string_into_groups_of_size_k/java_tests/Main.java +21 -0
  24. divide_a_string_into_groups_of_size_k/meta.json +133 -0
  25. divide_a_string_into_groups_of_size_k/ocaml_tests/main.ml +26 -0
  26. divide_a_string_into_groups_of_size_k/scala_tests/MySuite.scala +12 -0
  27. divide_an_array_into_subarrays_with_minimum_cost_i/haskell_tests/Main.hs +44 -0
  28. divide_an_array_into_subarrays_with_minimum_cost_i/java_tests/Main.java +24 -0
  29. divide_an_array_into_subarrays_with_minimum_cost_i/meta.json +181 -0
  30. divide_an_array_into_subarrays_with_minimum_cost_i/ocaml_tests/main.ml +45 -0
  31. divide_an_array_into_subarrays_with_minimum_cost_i/scala_tests/MySuite.scala +36 -0
  32. divide_an_array_into_subarrays_with_minimum_cost_ii/haskell_tests/Main.hs +0 -0
  33. divide_an_array_into_subarrays_with_minimum_cost_ii/java_tests/Main.java +25 -0
  34. divide_an_array_into_subarrays_with_minimum_cost_ii/meta.json +3 -0
  35. divide_an_array_into_subarrays_with_minimum_cost_ii/ocaml_tests/main.ml +0 -0
  36. divide_an_array_into_subarrays_with_minimum_cost_ii/scala_tests/MySuite.scala +0 -0
  37. divide_array_into_arrays_with_max_difference/haskell_tests/Main.hs +0 -0
  38. divide_array_into_arrays_with_max_difference/java_tests/Main.java +25 -0
  39. divide_array_into_arrays_with_max_difference/meta.json +3 -0
  40. divide_array_into_arrays_with_max_difference/ocaml_tests/main.ml +0 -0
  41. divide_array_into_arrays_with_max_difference/scala_tests/MySuite.scala +0 -0
  42. divide_array_into_equal_pairs/.DS_Store +0 -0
  43. divide_array_into_equal_pairs/haskell_tests/Main.hs +24 -0
  44. divide_array_into_equal_pairs/java_tests/Main.java +21 -0
  45. divide_array_into_equal_pairs/meta.json +0 -0
  46. divide_array_into_equal_pairs/ocaml_tests/main.ml +26 -0
  47. divide_array_into_equal_pairs/scala_tests/MySuite.scala +12 -0
  48. divide_intervals_into_minimum_number_of_groups/.DS_Store +0 -0
  49. divide_intervals_into_minimum_number_of_groups/haskell_tests/Main.hs +24 -0
  50. divide_intervals_into_minimum_number_of_groups/java_tests/Main.java +21 -0
.gitattributes CHANGED
@@ -107,3 +107,8 @@ destroy_sequential_targets/meta.json filter=lfs diff=lfs merge=lfs -text
107
  difference_between_maximum_and_minimum_price_sum/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
108
  difference_between_maximum_and_minimum_price_sum/meta.json filter=lfs diff=lfs merge=lfs -text
109
  difference_between_ones_and_zeros_in_row_and_column/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
107
  difference_between_maximum_and_minimum_price_sum/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
108
  difference_between_maximum_and_minimum_price_sum/meta.json filter=lfs diff=lfs merge=lfs -text
109
  difference_between_ones_and_zeros_in_row_and_column/meta.json filter=lfs diff=lfs merge=lfs -text
110
+ distribute_elements_into_two_arrays_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
111
+ distribute_elements_into_two_arrays_ii/meta.json filter=lfs diff=lfs merge=lfs -text
112
+ divide_an_array_into_subarrays_with_minimum_cost_ii/meta.json filter=lfs diff=lfs merge=lfs -text
113
+ divide_array_into_arrays_with_max_difference/meta.json filter=lfs diff=lfs merge=lfs -text
114
+ divide_intervals_into_minimum_number_of_groups/meta.json filter=lfs diff=lfs merge=lfs -text
distribute_candies_among_children_ii/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3201,
3
+ "name": "distribute_candies_among_children_ii",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/distribute-candies-among-children-ii/",
6
+ "date": "2023-10-28 00:00:00",
7
+ "task_description": "You are given two positive integers `n` and `limit`. Return _the **total number** of ways to distribute _`n` _candies among _`3`_ children such that no child gets more than _`limit`_ candies._ **Example 1:** ``` **Input:** n = 5, limit = 2 **Output:** 3 **Explanation:** There are 3 ways to distribute 5 candies such that no child gets more than 2 candies: (1, 2, 2), (2, 1, 2) and (2, 2, 1). ``` **Example 2:** ``` **Input:** n = 3, limit = 3 **Output:** 10 **Explanation:** There are 10 ways to distribute 3 candies such that no child gets more than 3 candies: (0, 0, 3), (0, 1, 2), (0, 2, 1), (0, 3, 0), (1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1), (2, 1, 0) and (3, 0, 0). ``` **Constraints:** `1 <= n <= 106` `1 <= limit <= 106`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "n = 5, limit = 2",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "n = 3, limit = 3",
17
+ "output": "10 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 416583,
24
+ 740667
25
+ ],
26
+ "output": 86771322820
27
+ },
28
+ {
29
+ "input": [
30
+ 311342,
31
+ 773767
32
+ ],
33
+ "output": 48467387496
34
+ },
35
+ {
36
+ "input": [
37
+ 859142,
38
+ 962517
39
+ ],
40
+ "output": 369063776796
41
+ },
42
+ {
43
+ "input": [
44
+ 858966,
45
+ 544227
46
+ ],
47
+ "output": 220321153738
48
+ },
49
+ {
50
+ "input": [
51
+ 703049,
52
+ 772005
53
+ ],
54
+ "output": 247140002775
55
+ },
56
+ {
57
+ "input": [
58
+ 395236,
59
+ 233626
60
+ ],
61
+ "output": 38929410138
62
+ },
63
+ {
64
+ "input": [
65
+ 340360,
66
+ 977359
67
+ ],
68
+ "output": 57922975341
69
+ },
70
+ {
71
+ "input": [
72
+ 981290,
73
+ 431034
74
+ ],
75
+ "output": 48613829391
76
+ },
77
+ {
78
+ "input": [
79
+ 287304,
80
+ 167006
81
+ ],
82
+ "output": 19564631512
83
+ },
84
+ {
85
+ "input": [
86
+ 626517,
87
+ 266609
88
+ ],
89
+ "output": 15018438016
90
+ }
91
+ ],
92
+ "haskell_template": "distributeCandies :: Int -> Int -> Int\ndistributeCandies n limit ",
93
+ "ocaml_template": "let distributeCandies (n: int) (limit: int) : int = ",
94
+ "scala_template": "def distributeCandies(n: Int,limit: Int): Int = { \n \n}",
95
+ "java_template": "class Solution {\n public long distributeCandies(int n, int limit) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def distributeCandies(self, n, limit):\n \"\"\"\n :type n: int\n :type limit: int\n :rtype: int\n \"\"\"\n "
97
+ }
distribute_candies_among_children_ii/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (distributeCandies 5 2)
12
+
13
+ let test2 _ = assert_equal 10 (distributeCandies 3 3)
14
+
15
+ let test3 _ = assert_equal 86771322820 (distributeCandies 416583 740667)
16
+
17
+ let test4 _ = assert_equal 48467387496 (distributeCandies 311342 773767)
18
+
19
+ let test5 _ = assert_equal 369063776796 (distributeCandies 859142 962517)
20
+
21
+ let test6 _ = assert_equal 220321153738 (distributeCandies 858966 544227)
22
+
23
+ let test7 _ = assert_equal 247140002775 (distributeCandies 703049 772005)
24
+
25
+ let test8 _ = assert_equal 38929410138 (distributeCandies 395236 233626)
26
+
27
+ let test9 _ = assert_equal 57922975341 (distributeCandies 340360 977359)
28
+
29
+ let test10 _ = assert_equal 48613829391 (distributeCandies 981290 431034)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for distributeCandies" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
distribute_candies_among_children_ii/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.distributeCandies(5,2), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.distributeCandies(3,3), 10)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.distributeCandies(416583,740667), BigInt("86771322820"))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.distributeCandies(311342,773767), BigInt("48467387496"))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.distributeCandies(859142,962517), BigInt("369063776796"))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.distributeCandies(858966,544227), BigInt("220321153738"))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.distributeCandies(703049,772005), BigInt("247140002775"))
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.distributeCandies(395236,233626), BigInt("38929410138"))
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.distributeCandies(340360,977359), BigInt("57922975341"))
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.distributeCandies(981290,431034), BigInt("48613829391"))
42
+ }
43
+
44
+ }
distribute_elements_into_two_arrays_i/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ resultArray :: [Int] -> [Int]
7
+ resultArray nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (resultArray [2,1,3])," [2,3,1] (resultArray [2,1,3]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (resultArray [5,4,3,8])," [5,3,4,8] (resultArray [5,4,3,8]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (resultArray [5, 6, 13, 73, 52, 17, 66, 58, 80, 14, 41, 57, 99, 98, 30, 32, 23, 55, 59, 91, 76, 34, 83, 81, 77, 20, 33, 24, 22, 85, 21, 35, 40, 88])," [5,6,13,73,52,17,66,58,80,14,41,57,99,98,30,32,23,55,59,91,76,34,83,81,77,20,33,24,22,85,21,35,40,88] (resultArray [5, 6, 13, 73, 52, 17, 66, 58, 80, 14, 41, 57, 99, 98, 30, 32, 23, 55, 59, 91, 76, 34, 83, 81, 77, 20, 33, 24, 22, 85, 21, 35, 40, 88]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (resultArray [35, 42, 84, 82, 9, 79, 31, 94, 18, 19, 59, 76, 22, 41, 78, 12, 16, 64, 1, 73, 29, 91, 2, 93, 23, 92, 67, 83, 50, 71, 27, 74, 44, 60, 38, 7, 54, 55, 10])," [35,79,31,94,18,19,59,76,22,41,78,12,16,64,1,42,84,82,9,73,29,91,2,93,23,92,67,83,50,71,27,74,44,60,38,7,54,55,10] (resultArray [35, 42, 84, 82, 9, 79, 31, 94, 18, 19, 59, 76, 22, 41, 78, 12, 16, 64, 1, 73, 29, 91, 2, 93, 23, 92, 67, 83, 50, 71, 27, 74, 44, 60, 38, 7, 54, 55, 10]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (resultArray [7, 57, 4, 94, 60, 80, 77, 100, 19, 13, 99, 90, 89, 68, 21, 31, 45, 41, 95, 12, 66, 17, 11, 85, 76, 63, 50])," [7,94,60,80,77,100,19,13,99,90,89,68,21,31,45,41,95,12,66,17,11,85,76,63,50,57,4] (resultArray [7, 57, 4, 94, 60, 80, 77, 100, 19, 13, 99, 90, 89, 68, 21, 31, 45, 41, 95, 12, 66, 17, 11, 85, 76, 63, 50]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (resultArray [51, 60, 82, 66, 86, 8, 59, 77, 44, 3, 22, 12, 40, 52, 28, 32, 24, 33, 50, 20, 90, 43, 27, 14, 17, 78, 1, 67, 64, 2, 74, 81, 97, 96, 84, 35, 65, 88, 56])," [51,59,77,44,3,67,64,2,74,81,97,96,84,35,65,88,56,60,82,66,86,8,22,12,40,52,28,32,24,33,50,20,90,43,27,14,17,78,1] (resultArray [51, 60, 82, 66, 86, 8, 59, 77, 44, 3, 22, 12, 40, 52, 28, 32, 24, 33, 50, 20, 90, 43, 27, 14, 17, 78, 1, 67, 64, 2, 74, 81, 97, 96, 84, 35, 65, 88, 56]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (resultArray [84, 27, 72, 1, 62, 76, 18, 24, 94, 59, 63, 25, 31])," [84,72,1,27,62,76,18,24,94,59,63,25,31] (resultArray [84, 27, 72, 1, 62, 76, 18, 24, 94, 59, 63, 25, 31]))
33
+
34
+
35
+ -- Grouping test cases
36
+ tests :: Test
37
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6]
38
+
39
+ -- Running the tests
40
+ main :: IO Counts
41
+ main = runTestTT tests
distribute_elements_into_two_arrays_i/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(Arrays.asList(2,3,1), resultArray(Arrays.asList(2,1,3)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(5,3,4,8), resultArray(Arrays.asList(5,4,3,8)));
18
+ }
19
+
20
+ }
distribute_elements_into_two_arrays_i/meta.json ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3347,
3
+ "name": "distribute_elements_into_two_arrays_i",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/distribute-elements-into-two-arrays-i/",
6
+ "date": "2024-02-25 00:00:00",
7
+ "task_description": "You are given a **1-indexed** array of **distinct** integers `nums` of length `n`. You need to distribute all the elements of `nums` between two arrays `arr1` and `arr2` using `n` operations. In the first operation, append `nums[1]` to `arr1`. In the second operation, append `nums[2]` to `arr2`. Afterwards, in the `ith` operation: If the last element of `arr1` is** greater** than the last element of `arr2`, append `nums[i]` to `arr1`. Otherwise, append `nums[i]` to `arr2`. The array `result` is formed by concatenating the arrays `arr1` and `arr2`. For example, if `arr1 == [1,2,3]` and `arr2 == [4,5,6]`, then `result = [1,2,3,4,5,6]`. Return _the array_ `result`. **Example 1:** ``` **Input:** nums = [2,1,3] **Output:** [2,3,1] **Explanation:** After the first 2 operations, arr1 = [2] and arr2 = [1]. In the 3rd operation, as the last element of arr1 is greater than the last element of arr2 (2 > 1), append nums[3] to arr1. After 3 operations, arr1 = [2,3] and arr2 = [1]. Hence, the array result formed by concatenation is [2,3,1]. ``` **Example 2:** ``` **Input:** nums = [5,4,3,8] **Output:** [5,3,4,8] **Explanation:** After the first 2 operations, arr1 = [5] and arr2 = [4]. In the 3rd operation, as the last element of arr1 is greater than the last element of arr2 (5 > 4), append nums[3] to arr1, hence arr1 becomes [5,3]. In the 4th operation, as the last element of arr2 is greater than the last element of arr1 (4 > 3), append nums[4] to arr2, hence arr2 becomes [4,8]. After 4 operations, arr1 = [5,3] and arr2 = [4,8]. Hence, the array result formed by concatenation is [5,3,4,8]. ``` **Constraints:** `3 <= n <= 50` `1 <= nums[i] <= 100` All elements in `nums` are distinct.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [2,1,3]",
12
+ "output": "[2,3,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [5,4,3,8]",
17
+ "output": "[5,3,4,8] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 5,
24
+ 6,
25
+ 13,
26
+ 73,
27
+ 52,
28
+ 17,
29
+ 66,
30
+ 58,
31
+ 80,
32
+ 14,
33
+ 41,
34
+ 57,
35
+ 99,
36
+ 98,
37
+ 30,
38
+ 32,
39
+ 23,
40
+ 55,
41
+ 59,
42
+ 91,
43
+ 76,
44
+ 34,
45
+ 83,
46
+ 81,
47
+ 77,
48
+ 20,
49
+ 33,
50
+ 24,
51
+ 22,
52
+ 85,
53
+ 21,
54
+ 35,
55
+ 40,
56
+ 88
57
+ ],
58
+ "output": [
59
+ 5,
60
+ 6,
61
+ 13,
62
+ 73,
63
+ 52,
64
+ 17,
65
+ 66,
66
+ 58,
67
+ 80,
68
+ 14,
69
+ 41,
70
+ 57,
71
+ 99,
72
+ 98,
73
+ 30,
74
+ 32,
75
+ 23,
76
+ 55,
77
+ 59,
78
+ 91,
79
+ 76,
80
+ 34,
81
+ 83,
82
+ 81,
83
+ 77,
84
+ 20,
85
+ 33,
86
+ 24,
87
+ 22,
88
+ 85,
89
+ 21,
90
+ 35,
91
+ 40,
92
+ 88
93
+ ]
94
+ },
95
+ {
96
+ "input": [
97
+ 35,
98
+ 42,
99
+ 84,
100
+ 82,
101
+ 9,
102
+ 79,
103
+ 31,
104
+ 94,
105
+ 18,
106
+ 19,
107
+ 59,
108
+ 76,
109
+ 22,
110
+ 41,
111
+ 78,
112
+ 12,
113
+ 16,
114
+ 64,
115
+ 1,
116
+ 73,
117
+ 29,
118
+ 91,
119
+ 2,
120
+ 93,
121
+ 23,
122
+ 92,
123
+ 67,
124
+ 83,
125
+ 50,
126
+ 71,
127
+ 27,
128
+ 74,
129
+ 44,
130
+ 60,
131
+ 38,
132
+ 7,
133
+ 54,
134
+ 55,
135
+ 10
136
+ ],
137
+ "output": [
138
+ 35,
139
+ 79,
140
+ 31,
141
+ 94,
142
+ 18,
143
+ 19,
144
+ 59,
145
+ 76,
146
+ 22,
147
+ 41,
148
+ 78,
149
+ 12,
150
+ 16,
151
+ 64,
152
+ 1,
153
+ 42,
154
+ 84,
155
+ 82,
156
+ 9,
157
+ 73,
158
+ 29,
159
+ 91,
160
+ 2,
161
+ 93,
162
+ 23,
163
+ 92,
164
+ 67,
165
+ 83,
166
+ 50,
167
+ 71,
168
+ 27,
169
+ 74,
170
+ 44,
171
+ 60,
172
+ 38,
173
+ 7,
174
+ 54,
175
+ 55,
176
+ 10
177
+ ]
178
+ },
179
+ {
180
+ "input": [
181
+ 7,
182
+ 57,
183
+ 4,
184
+ 94,
185
+ 60,
186
+ 80,
187
+ 77,
188
+ 100,
189
+ 19,
190
+ 13,
191
+ 99,
192
+ 90,
193
+ 89,
194
+ 68,
195
+ 21,
196
+ 31,
197
+ 45,
198
+ 41,
199
+ 95,
200
+ 12,
201
+ 66,
202
+ 17,
203
+ 11,
204
+ 85,
205
+ 76,
206
+ 63,
207
+ 50
208
+ ],
209
+ "output": [
210
+ 7,
211
+ 94,
212
+ 60,
213
+ 80,
214
+ 77,
215
+ 100,
216
+ 19,
217
+ 13,
218
+ 99,
219
+ 90,
220
+ 89,
221
+ 68,
222
+ 21,
223
+ 31,
224
+ 45,
225
+ 41,
226
+ 95,
227
+ 12,
228
+ 66,
229
+ 17,
230
+ 11,
231
+ 85,
232
+ 76,
233
+ 63,
234
+ 50,
235
+ 57,
236
+ 4
237
+ ]
238
+ },
239
+ {
240
+ "input": [
241
+ 51,
242
+ 60,
243
+ 82,
244
+ 66,
245
+ 86,
246
+ 8,
247
+ 59,
248
+ 77,
249
+ 44,
250
+ 3,
251
+ 22,
252
+ 12,
253
+ 40,
254
+ 52,
255
+ 28,
256
+ 32,
257
+ 24,
258
+ 33,
259
+ 50,
260
+ 20,
261
+ 90,
262
+ 43,
263
+ 27,
264
+ 14,
265
+ 17,
266
+ 78,
267
+ 1,
268
+ 67,
269
+ 64,
270
+ 2,
271
+ 74,
272
+ 81,
273
+ 97,
274
+ 96,
275
+ 84,
276
+ 35,
277
+ 65,
278
+ 88,
279
+ 56
280
+ ],
281
+ "output": [
282
+ 51,
283
+ 59,
284
+ 77,
285
+ 44,
286
+ 3,
287
+ 67,
288
+ 64,
289
+ 2,
290
+ 74,
291
+ 81,
292
+ 97,
293
+ 96,
294
+ 84,
295
+ 35,
296
+ 65,
297
+ 88,
298
+ 56,
299
+ 60,
300
+ 82,
301
+ 66,
302
+ 86,
303
+ 8,
304
+ 22,
305
+ 12,
306
+ 40,
307
+ 52,
308
+ 28,
309
+ 32,
310
+ 24,
311
+ 33,
312
+ 50,
313
+ 20,
314
+ 90,
315
+ 43,
316
+ 27,
317
+ 14,
318
+ 17,
319
+ 78,
320
+ 1
321
+ ]
322
+ },
323
+ {
324
+ "input": [
325
+ 84,
326
+ 27,
327
+ 72,
328
+ 1,
329
+ 62,
330
+ 76,
331
+ 18,
332
+ 24,
333
+ 94,
334
+ 59,
335
+ 63,
336
+ 25,
337
+ 31
338
+ ],
339
+ "output": [
340
+ 84,
341
+ 72,
342
+ 1,
343
+ 27,
344
+ 62,
345
+ 76,
346
+ 18,
347
+ 24,
348
+ 94,
349
+ 59,
350
+ 63,
351
+ 25,
352
+ 31
353
+ ]
354
+ }
355
+ ],
356
+ "haskell_template": "resultArray :: [Int] -> [Int]\nresultArray nums ",
357
+ "ocaml_template": "let resultArray (nums: int list) : int list = ",
358
+ "scala_template": "def resultArray(nums: List[Int]): List[Int] = { \n \n}",
359
+ "java_template": "class Solution {\n public int[] resultArray(int[] nums) {\n \n }\n}",
360
+ "python_template": "class Solution(object):\n def resultArray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
361
+ }
distribute_elements_into_two_arrays_i/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let resultArray (nums: int list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [2;3;1] (resultArray [2;1;3])
13
+
14
+ let test2 _ = assert_equal [5;3;4;8] (resultArray [5;4;3;8])
15
+
16
+ let test3 _ = assert_equal [5;3;4;8] (resultArray [5; 6; 13; 73; 52; 17; 66; 58; 80; 14; 41; 57; 99; 98; 30; 32; 23; 55; 59; 91; 76; 34; 83; 81; 77; 20; 33; 24; 22; 85; 21; 35; 40; 88])
17
+
18
+ let test4 _ = assert_equal [5;3;4;8] (resultArray [35; 42; 84; 82; 9; 79; 31; 94; 18; 19; 59; 76; 22; 41; 78; 12; 16; 64; 1; 73; 29; 91; 2; 93; 23; 92; 67; 83; 50; 71; 27; 74; 44; 60; 38; 7; 54; 55; 10])
19
+
20
+ let test5 _ = assert_equal [5;3;4;8] (resultArray [7; 57; 4; 94; 60; 80; 77; 100; 19; 13; 99; 90; 89; 68; 21; 31; 45; 41; 95; 12; 66; 17; 11; 85; 76; 63; 50])
21
+
22
+ let test6 _ = assert_equal [5;3;4;8] (resultArray [51; 60; 82; 66; 86; 8; 59; 77; 44; 3; 22; 12; 40; 52; 28; 32; 24; 33; 50; 20; 90; 43; 27; 14; 17; 78; 1; 67; 64; 2; 74; 81; 97; 96; 84; 35; 65; 88; 56])
23
+
24
+ let test7 _ = assert_equal [5;3;4;8] (resultArray [84; 27; 72; 1; 62; 76; 18; 24; 94; 59; 63; 25; 31])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for resultArray" >::: [
29
+
30
+ "test1" >:: test1;
31
+ "test2" >:: test2;
32
+ "test3" >:: test3;
33
+ "test4" >:: test4;
34
+ "test5" >:: test5;
35
+ "test6" >:: test6;
36
+ "test7" >:: test7;
37
+ ]
38
+
39
+
40
+ (* Running the tests *)
41
+ let () = run_test_tt_main suite
42
+ end
distribute_elements_into_two_arrays_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.resultArray(List(2,1,3)), List(2,3,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.resultArray(List(5,4,3,8)), List(5,3,4,8))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.resultArray(5,6,13,73,52,17,66,58,80,14,41,57,99,98,30,32,23,55,59,91,76,34,83,81,77,20,33,24,22,85,21,35,40,88), List(5,6,13,73,52,17,66,58,80,14,41,57,99,98,30,32,23,55,59,91,76,34,83,81,77,20,33,24,22,85,21,35,40,88))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.resultArray(35,42,84,82,9,79,31,94,18,19,59,76,22,41,78,12,16,64,1,73,29,91,2,93,23,92,67,83,50,71,27,74,44,60,38,7,54,55,10), List(35,79,31,94,18,19,59,76,22,41,78,12,16,64,1,42,84,82,9,73,29,91,2,93,23,92,67,83,50,71,27,74,44,60,38,7,54,55,10))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.resultArray(7,57,4,94,60,80,77,100,19,13,99,90,89,68,21,31,45,41,95,12,66,17,11,85,76,63,50), List(7,94,60,80,77,100,19,13,99,90,89,68,21,31,45,41,95,12,66,17,11,85,76,63,50,57,4))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.resultArray(51,60,82,66,86,8,59,77,44,3,22,12,40,52,28,32,24,33,50,20,90,43,27,14,17,78,1,67,64,2,74,81,97,96,84,35,65,88,56), List(51,59,77,44,3,67,64,2,74,81,97,96,84,35,65,88,56,60,82,66,86,8,22,12,40,52,28,32,24,33,50,20,90,43,27,14,17,78,1))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.resultArray(84,27,72,1,62,76,18,24,94,59,63,25,31), List(84,72,1,27,62,76,18,24,94,59,63,25,31))
30
+ }
31
+
32
+ }
distribute_elements_into_two_arrays_ii/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ee4089a10a10236f0892a7283c647fc2b3d17e22821503943628552987adf6b
3
+ size 12392371
distribute_elements_into_two_arrays_ii/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(Arrays.asList(2,3,1,3), resultArray(Arrays.asList(2,1,3,3)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(5,3,1,2,14), resultArray(Arrays.asList(5,14,3,1,2)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(Arrays.asList(3,3,3,3), resultArray(Arrays.asList(3,3,3,3)));
22
+ }
23
+
24
+ }
distribute_elements_into_two_arrays_ii/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ff15905e33325511284afcb31aa3bd7b2c66cc4b84a61c6fbb057cd17f1ee47
3
+ size 21047879
distribute_elements_into_two_arrays_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
distribute_elements_into_two_arrays_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
distribute_money_to_maximum_children/.DS_Store ADDED
Binary file (6.15 kB). View file
 
distribute_money_to_maximum_children/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (distMoney 20 3)," 1 (distMoney 20 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (distMoney 16 2)," 2 (distMoney 16 2))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
distribute_money_to_maximum_children/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(1, distMoney(20, 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, distMoney(16, 2));
19
+ }
20
+
21
+ }
distribute_money_to_maximum_children/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2663,
3
+ "name": "distribute_money_to_maximum_children",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/distribute-money-to-maximum-children/",
6
+ "date": "1677888000000",
7
+ "task_description": "You are given an integer `money` denoting the amount of money (in dollars) that you have and another integer `children` denoting the number of children that you must distribute the money to. You have to distribute the money according to the following rules: All money must be distributed. Everyone must receive at least `1` dollar. Nobody receives `4` dollars. Return _the **maximum** number of children who may receive **exactly** _`8` _dollars if you distribute the money according to the aforementioned rules_. If there is no way to distribute the money, return `-1`. **Example 1:** ``` **Input:** money = 20, children = 3 **Output:** 1 **Explanation:** The maximum number of children with 8 dollars will be 1. One of the ways to distribute the money is: - 8 dollars to the first child. - 9 dollars to the second child. - 3 dollars to the third child. It can be proven that no distribution exists such that number of children getting 8 dollars is greater than 1. ``` **Example 2:** ``` **Input:** money = 16, children = 2 **Output:** 2 **Explanation:** Each child can be given 8 dollars. ``` **Constraints:** `1 <= money <= 200` `2 <= children <= 30`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "money = 20, children = 3",
12
+ "output": "1 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "money = 16, children = 2",
17
+ "output": "2 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 161,
24
+ 4
25
+ ],
26
+ "output": 3
27
+ },
28
+ {
29
+ "input": [
30
+ 181,
31
+ 2
32
+ ],
33
+ "output": 1
34
+ },
35
+ {
36
+ "input": [
37
+ 83,
38
+ 6
39
+ ],
40
+ "output": 5
41
+ },
42
+ {
43
+ "input": [
44
+ 134,
45
+ 26
46
+ ],
47
+ "output": 15
48
+ },
49
+ {
50
+ "input": [
51
+ 189,
52
+ 25
53
+ ],
54
+ "output": 23
55
+ },
56
+ {
57
+ "input": [
58
+ 95,
59
+ 29
60
+ ],
61
+ "output": 9
62
+ },
63
+ {
64
+ "input": [
65
+ 145,
66
+ 6
67
+ ],
68
+ "output": 5
69
+ },
70
+ {
71
+ "input": [
72
+ 161,
73
+ 14
74
+ ],
75
+ "output": 13
76
+ },
77
+ {
78
+ "input": [
79
+ 35,
80
+ 13
81
+ ],
82
+ "output": 3
83
+ },
84
+ {
85
+ "input": [
86
+ 135,
87
+ 22
88
+ ],
89
+ "output": 16
90
+ }
91
+ ],
92
+ "haskell_template": "distMoney :: Int -> Int -> Int\ndistMoney money children ",
93
+ "ocaml_template": "let distMoney (money: int) (children: int) : int = ",
94
+ "scala_template": "def distMoney(money: Int,children: Int): Int = { \n \n}",
95
+ "java_template": "public static int distMoney(int money, int children) {\n\n}",
96
+ "python_template": "class Solution(object):\n def distMoney(self, money, children):\n \"\"\"\n :type money: int\n :type children: int\n :rtype: int\n \"\"\"\n "
97
+ }
distribute_money_to_maximum_children/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 1 (distMoney 20 3)
12
+
13
+ let test2 _ = assert_equal 2 (distMoney 16 2)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for distMoney" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
distribute_money_to_maximum_children/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.distMoney(20,3), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.distMoney(16,2), 2)
10
+ }
11
+
12
+ }
divide_a_string_into_groups_of_size_k/.DS_Store ADDED
Binary file (6.15 kB). View file
 
divide_a_string_into_groups_of_size_k/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (divideString \"abcdefghi \" 3 \"x \")," ["abc","def","ghi"] (divideString "abcdefghi" 3 "x"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (divideString \"abcdefghij \" 3 \"x \")," ["abc","def","ghi","jxx"] (divideString "abcdefghij" 3 "x"))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
divide_a_string_into_groups_of_size_k/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList("abc","def","ghi")), divideString("abcdefghi", 3, "x"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList("abc","def","ghi","jxx")), divideString("abcdefghij", 3, "x"));
19
+ }
20
+
21
+ }
divide_a_string_into_groups_of_size_k/meta.json ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2260,
3
+ "name": "divide_a_string_into_groups_of_size_k",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/",
6
+ "date": "1641686400000",
7
+ "task_description": "A string `s` can be partitioned into groups of size `k` using the following procedure: The first group consists of the first `k` characters of the string, the second group consists of the next `k` characters of the string, and so on. Each element can be a part of **exactly one** group. For the last group, if the string **does not** have `k` characters remaining, a character `fill` is used to complete the group. Note that the partition is done so that after removing the `fill` character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be `s`. Given the string `s`, the size of each group `k` and the character `fill`, return _a string array denoting the **composition of every group** _`s`_ has been divided into, using the above procedure_. **Example 1:** ``` **Input:** s = \"abcdefghi\", k = 3, fill = \"x\" **Output:** [\"abc\",\"def\",\"ghi\"] **Explanation:** The first 3 characters \"abc\" form the first group. The next 3 characters \"def\" form the second group. The last 3 characters \"ghi\" form the third group. Since all groups can be completely filled by characters from the string, we do not need to use fill. Thus, the groups formed are \"abc\", \"def\", and \"ghi\". ``` **Example 2:** ``` **Input:** s = \"abcdefghij\", k = 3, fill = \"x\" **Output:** [\"abc\",\"def\",\"ghi\",\"jxx\"] **Explanation:** Similar to the previous example, we are forming the first three groups \"abc\", \"def\", and \"ghi\". For the last group, we can only use the character 'j' from the string. To complete this group, we add 'x' twice. Thus, the 4 groups formed are \"abc\", \"def\", \"ghi\", and \"jxx\". ``` **Constraints:** `1 <= s.length <= 100` `s` consists of lowercase English letters only. `1 <= k <= 100` `fill` is a lowercase English letter.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"abcdefghi\", k = 3, fill = \"x\"",
12
+ "output": "[\"abc\",\"def\",\"ghi\"] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"abcdefghij\", k = 3, fill = \"x\"",
17
+ "output": "[\"abc\",\"def\",\"ghi\",\"jxx\"] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"fkgqjigbdgsxuotdyypqjvtetzctaroenbifhdazlskbmgvbmysvrikfjfcenmtycilvy\"",
24
+ 16,
25
+ "\"i\""
26
+ ],
27
+ "output": [
28
+ "fkgqjigbdgsxuotd",
29
+ "yypqjvtetzctaroe",
30
+ "nbifhdazlskbmgvb",
31
+ "mysvrikfjfcenmty",
32
+ "cilvyiiiiiiiiiii"
33
+ ]
34
+ },
35
+ {
36
+ "input": [
37
+ "\"bddueajpkunbhnqbfguoywrfhvxnigmr\"",
38
+ 36,
39
+ "\"i\""
40
+ ],
41
+ "output": [
42
+ "bddueajpkunbhnqbfguoywrfhvxnigmriiii"
43
+ ]
44
+ },
45
+ {
46
+ "input": [
47
+ "\"mwylwwhnkvakdjcnefbdugvdnhvm\"",
48
+ 43,
49
+ "\"e\""
50
+ ],
51
+ "output": [
52
+ "mwylwwhnkvakdjcnefbdugvdnhvmeeeeeeeeeeeeeee"
53
+ ]
54
+ },
55
+ {
56
+ "input": [
57
+ "\"indjae\"",
58
+ 66,
59
+ "\"z\""
60
+ ],
61
+ "output": [
62
+ "indjaezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
63
+ ]
64
+ },
65
+ {
66
+ "input": [
67
+ "\"pwlwkkpahjrnsicbuzfvqojzfjugyhatmlfedfltxyiiegevqgusagrhxpbpcvceutxcowatrwmnmcrxbvgqptditpqmvye\"",
68
+ 48,
69
+ "\"a\""
70
+ ],
71
+ "output": [
72
+ "pwlwkkpahjrnsicbuzfvqojzfjugyhatmlfedfltxyiiegev",
73
+ "qgusagrhxpbpcvceutxcowatrwmnmcrxbvgqptditpqmvyea"
74
+ ]
75
+ },
76
+ {
77
+ "input": [
78
+ "\"putzcpowmxhaxfewximch\"",
79
+ 94,
80
+ "\"w\""
81
+ ],
82
+ "output": [
83
+ "putzcpowmxhaxfewximchwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
84
+ ]
85
+ },
86
+ {
87
+ "input": [
88
+ "\"yrjkthlycdnnknaysjksdcdzzuqidqeqm\"",
89
+ 100,
90
+ "\"g\""
91
+ ],
92
+ "output": [
93
+ "yrjkthlycdnnknaysjksdcdzzuqidqeqmggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"
94
+ ]
95
+ },
96
+ {
97
+ "input": [
98
+ "zbxigcaqprjaffizikgyugjqaikgidkqoijfbachctdrdxq",
99
+ 43,
100
+ "o"
101
+ ],
102
+ "output": [
103
+ "zbxigcaqprjaffizikgyugjqaikgidkqoijfbachctd",
104
+ "rdxqooooooooooooooooooooooooooooooooooooooo"
105
+ ]
106
+ },
107
+ {
108
+ "input": [
109
+ "trvaizmlfnranrshpfnvj",
110
+ 35,
111
+ "r"
112
+ ],
113
+ "output": [
114
+ "trvaizmlfnranrshpfnvjrrrrrrrrrrrrrr"
115
+ ]
116
+ },
117
+ {
118
+ "input": [
119
+ "mkrnoghwppgbtnuarxtjxvxlblqnbdujdzgefbftktcukkb",
120
+ 55,
121
+ "p"
122
+ ],
123
+ "output": [
124
+ "mkrnoghwppgbtnuarxtjxvxlblqnbdujdzgefbftktcukkbpppppppp"
125
+ ]
126
+ }
127
+ ],
128
+ "haskell_template": "divideString :: String -> Int -> String -> [String]\ndivideString s k fill ",
129
+ "ocaml_template": "let divideString (s: string) (k: int) (fill: string) : string list = ",
130
+ "scala_template": "def divideString(s: String,k: Int,fill: String): List[String] = { \n \n}",
131
+ "java_template": "public static List<String> divideString(String s, int k, String fill) {\n\n}",
132
+ "python_template": "class Solution(object):\n def divideString(self, s, k, fill):\n \"\"\"\n :type s: str\n :type k: int\n :type fill: str\n :rtype: List[str]\n \"\"\"\n "
133
+ }
divide_a_string_into_groups_of_size_k/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal ["abc";"def";"ghi"] (divideString "abcdefghi" 3 "x")
12
+
13
+ let test2 _ = assert_equal ["abc";"def";"ghi";"jxx"] (divideString "abcdefghij" 3 "x")
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for divideString" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
divide_a_string_into_groups_of_size_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.divideString("abcdefghi",3,"x"), List("abc","def","ghi"))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.divideString("abcdefghij",3,"x"), List("abc","def","ghi","jxx"))
10
+ }
11
+
12
+ }
divide_an_array_into_subarrays_with_minimum_cost_i/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimumCost :: [Int] -> Int
7
+ minimumCost nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimumCost [1,2,3,12])," 6 (minimumCost [1,2,3,12]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimumCost [5,4,3])," 12 (minimumCost [5,4,3]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimumCost [10,3,1,1])," 12 (minimumCost [10,3,1,1]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimumCost [34, 1, 2, 5, 15, 18, 22, 32, 49])," 37 (minimumCost [34, 1, 2, 5, 15, 18, 22, 32, 49]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimumCost [4, 4, 5, 7, 7, 23, 29, 12, 17, 24, 20, 15, 24, 25, 20, 31, 23, 16, 18, 22, 27, 17, 16, 11, 18, 8, 19, 32, 35, 36, 48, 42, 46, 49, 37, 44, 47, 37, 45, 50, 35, 33, 34, 41, 46, 48, 49])," 13 (minimumCost [4, 4, 5, 7, 7, 23, 29, 12, 17, 24, 20, 15, 24, 25, 20, 31, 23, 16, 18, 22, 27, 17, 16, 11, 18, 8, 19, 32, 35, 36, 48, 42, 46, 49, 37, 44, 47, 37, 45, 50, 35, 33, 34, 41, 46, 48, 49]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimumCost [48, 1, 4, 8, 8, 12, 15, 16, 17, 17, 17, 18, 20, 22, 25, 22, 27, 26, 30, 30, 39, 46, 34, 31, 42, 44])," 53 (minimumCost [48, 1, 4, 8, 8, 12, 15, 16, 17, 17, 17, 18, 20, 22, 25, 22, 27, 26, 30, 30, 39, 46, 34, 31, 42, 44]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimumCost [50, 5, 5, 9, 28, 12, 18, 13, 29, 33, 35, 35, 38, 38, 49, 50, 40, 47])," 60 (minimumCost [50, 5, 5, 9, 28, 12, 18, 13, 29, 33, 35, 35, 38, 38, 49, 50, 40, 47]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (minimumCost [29, 1, 4, 5, 5, 40, 41, 20, 25, 7, 32, 35, 38, 32, 47, 34, 22, 47, 43, 43, 10, 21, 20, 29])," 34 (minimumCost [29, 1, 4, 5, 5, 40, 41, 20, 25, 7, 32, 35, 38, 32, 47, 34, 22, 47, 43, 43, 10, 21, 20, 29]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
divide_an_array_into_subarrays_with_minimum_cost_i/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(6, minimumCost(Arrays.asList(1,2,3,12)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(12, minimumCost(Arrays.asList(5,4,3)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(12, minimumCost(Arrays.asList(10,3,1,1)));
22
+ }
23
+
24
+ }
divide_an_array_into_subarrays_with_minimum_cost_i/meta.json ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3263,
3
+ "name": "divide_an_array_into_subarrays_with_minimum_cost_i",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/",
6
+ "date": "2024-01-06 00:00:00",
7
+ "task_description": "You are given an array of integers `nums` of length `n`. The **cost** of an array is the value of its **first** element. For example, the cost of `[1,2,3]` is `1` while the cost of `[3,4,1]` is `3`. You need to divide `nums` into `3` **disjoint contiguous **subarrays. Return _the **minimum** possible **sum** of the cost of these subarrays_. **Example 1:** ``` **Input:** nums = [1,2,3,12] **Output:** 6 **Explanation:** The best possible way to form 3 subarrays is: [1], [2], and [3,12] at a total cost of 1 + 2 + 3 = 6. The other possible ways to form 3 subarrays are: - [1], [2,3], and [12] at a total cost of 1 + 2 + 12 = 15. - [1,2], [3], and [12] at a total cost of 1 + 3 + 12 = 16. ``` **Example 2:** ``` **Input:** nums = [5,4,3] **Output:** 12 **Explanation:** The best possible way to form 3 subarrays is: [5], [4], and [3] at a total cost of 5 + 4 + 3 = 12. It can be shown that 12 is the minimum cost achievable. ``` **Example 3:** ``` **Input:** nums = [10,3,1,1] **Output:** 12 **Explanation:** The best possible way to form 3 subarrays is: [10,3], [1], and [1] at a total cost of 10 + 1 + 1 = 12. It can be shown that 12 is the minimum cost achievable. ``` **Constraints:** `3 <= n <= 50` `1 <= nums[i] <= 50`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,3,12]",
12
+ "output": "6 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [5,4,3]",
17
+ "output": "12 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [10,3,1,1]",
22
+ "output": "12 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 34,
29
+ 1,
30
+ 2,
31
+ 5,
32
+ 15,
33
+ 18,
34
+ 22,
35
+ 32,
36
+ 49
37
+ ],
38
+ "output": 37
39
+ },
40
+ {
41
+ "input": [
42
+ 4,
43
+ 4,
44
+ 5,
45
+ 7,
46
+ 7,
47
+ 23,
48
+ 29,
49
+ 12,
50
+ 17,
51
+ 24,
52
+ 20,
53
+ 15,
54
+ 24,
55
+ 25,
56
+ 20,
57
+ 31,
58
+ 23,
59
+ 16,
60
+ 18,
61
+ 22,
62
+ 27,
63
+ 17,
64
+ 16,
65
+ 11,
66
+ 18,
67
+ 8,
68
+ 19,
69
+ 32,
70
+ 35,
71
+ 36,
72
+ 48,
73
+ 42,
74
+ 46,
75
+ 49,
76
+ 37,
77
+ 44,
78
+ 47,
79
+ 37,
80
+ 45,
81
+ 50,
82
+ 35,
83
+ 33,
84
+ 34,
85
+ 41,
86
+ 46,
87
+ 48,
88
+ 49
89
+ ],
90
+ "output": 13
91
+ },
92
+ {
93
+ "input": [
94
+ 48,
95
+ 1,
96
+ 4,
97
+ 8,
98
+ 8,
99
+ 12,
100
+ 15,
101
+ 16,
102
+ 17,
103
+ 17,
104
+ 17,
105
+ 18,
106
+ 20,
107
+ 22,
108
+ 25,
109
+ 22,
110
+ 27,
111
+ 26,
112
+ 30,
113
+ 30,
114
+ 39,
115
+ 46,
116
+ 34,
117
+ 31,
118
+ 42,
119
+ 44
120
+ ],
121
+ "output": 53
122
+ },
123
+ {
124
+ "input": [
125
+ 50,
126
+ 5,
127
+ 5,
128
+ 9,
129
+ 28,
130
+ 12,
131
+ 18,
132
+ 13,
133
+ 29,
134
+ 33,
135
+ 35,
136
+ 35,
137
+ 38,
138
+ 38,
139
+ 49,
140
+ 50,
141
+ 40,
142
+ 47
143
+ ],
144
+ "output": 60
145
+ },
146
+ {
147
+ "input": [
148
+ 29,
149
+ 1,
150
+ 4,
151
+ 5,
152
+ 5,
153
+ 40,
154
+ 41,
155
+ 20,
156
+ 25,
157
+ 7,
158
+ 32,
159
+ 35,
160
+ 38,
161
+ 32,
162
+ 47,
163
+ 34,
164
+ 22,
165
+ 47,
166
+ 43,
167
+ 43,
168
+ 10,
169
+ 21,
170
+ 20,
171
+ 29
172
+ ],
173
+ "output": 34
174
+ }
175
+ ],
176
+ "haskell_template": "minimumCost :: [Int] -> Int\nminimumCost nums ",
177
+ "ocaml_template": "let minimumCost (nums: int list) : int = ",
178
+ "scala_template": "def minimumCost(nums: List[Int]): Int = { \n \n}",
179
+ "java_template": "class Solution {\n public int minimumCost(int[] nums) {\n \n }\n}",
180
+ "python_template": "class Solution(object):\n def minimumCost(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
181
+ }
divide_an_array_into_subarrays_with_minimum_cost_i/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimumCost (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 6 (minimumCost [1;2;3;12])
13
+
14
+ let test2 _ = assert_equal 12 (minimumCost [5;4;3])
15
+
16
+ let test3 _ = assert_equal 12 (minimumCost [10;3;1;1])
17
+
18
+ let test4 _ = assert_equal 12 (minimumCost [34; 1; 2; 5; 15; 18; 22; 32; 49])
19
+
20
+ let test5 _ = assert_equal 12 (minimumCost [4; 4; 5; 7; 7; 23; 29; 12; 17; 24; 20; 15; 24; 25; 20; 31; 23; 16; 18; 22; 27; 17; 16; 11; 18; 8; 19; 32; 35; 36; 48; 42; 46; 49; 37; 44; 47; 37; 45; 50; 35; 33; 34; 41; 46; 48; 49])
21
+
22
+ let test6 _ = assert_equal 12 (minimumCost [48; 1; 4; 8; 8; 12; 15; 16; 17; 17; 17; 18; 20; 22; 25; 22; 27; 26; 30; 30; 39; 46; 34; 31; 42; 44])
23
+
24
+ let test7 _ = assert_equal 12 (minimumCost [50; 5; 5; 9; 28; 12; 18; 13; 29; 33; 35; 35; 38; 38; 49; 50; 40; 47])
25
+
26
+ let test8 _ = assert_equal 12 (minimumCost [29; 1; 4; 5; 5; 40; 41; 20; 25; 7; 32; 35; 38; 32; 47; 34; 22; 47; 43; 43; 10; 21; 20; 29])
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for minimumCost" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end
divide_an_array_into_subarrays_with_minimum_cost_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumCost(List(1,2,3,12)), 6)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumCost(List(5,4,3)), 12)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumCost(List(10,3,1,1)), 12)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumCost(34,1,2,5,15,18,22,32,49), 37)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumCost(4,4,5,7,7,23,29,12,17,24,20,15,24,25,20,31,23,16,18,22,27,17,16,11,18,8,19,32,35,36,48,42,46,49,37,44,47,37,45,50,35,33,34,41,46,48,49), 13)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumCost(48,1,4,8,8,12,15,16,17,17,17,18,20,22,25,22,27,26,30,30,39,46,34,31,42,44), 53)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumCost(50,5,5,9,28,12,18,13,29,33,35,35,38,38,49,50,40,47), 60)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumCost(29,1,4,5,5,40,41,20,25,7,32,35,38,32,47,34,22,47,43,43,10,21,20,29), 34)
34
+ }
35
+
36
+ }
divide_an_array_into_subarrays_with_minimum_cost_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
divide_an_array_into_subarrays_with_minimum_cost_ii/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(5, minimumCost(new ArrayList<>(Arrays.asList(1,3,2,6,4,2)), 3, 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(15, minimumCost(new ArrayList<>(Arrays.asList(10,1,2,2,2,1)), 4, 3));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(36, minimumCost(new ArrayList<>(Arrays.asList(10,8,18,9)), 3, 1));
23
+ }
24
+
25
+ }
divide_an_array_into_subarrays_with_minimum_cost_ii/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97753e180440ba0032c4b56ed7284790cf29f15712cbc3b3416eb97483cbaa1a
3
+ size 12004606
divide_an_array_into_subarrays_with_minimum_cost_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
divide_an_array_into_subarrays_with_minimum_cost_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
divide_array_into_arrays_with_max_difference/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
divide_array_into_arrays_with_max_difference/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1,3)),new ArrayList<>(Arrays.asList(3,4,5)),new ArrayList<>(Arrays.asList(7,8,9)))), divideArray(new ArrayList<>(Arrays.asList(1,3,4,8,7,9,3,5,1)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(), divideArray(new ArrayList<>(Arrays.asList(2,4,2,2,5,2)), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,2,12)),new ArrayList<>(Arrays.asList(4,8,5)),new ArrayList<>(Arrays.asList(5,9,7)),new ArrayList<>(Arrays.asList(7,8,5)),new ArrayList<>(Arrays.asList(5,9,10)),new ArrayList<>(Arrays.asList(11,12,2)))), divideArray(new ArrayList<>(Arrays.asList(4,2,9,8,2,12,7,12,10,5,8,5,5,7,9,2,5,11)), 14));
23
+ }
24
+
25
+ }
divide_array_into_arrays_with_max_difference/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f680a7eba0e14f79b464acca3429a1b1234eec48343c59ea1c0979b629907250
3
+ size 51321202
divide_array_into_arrays_with_max_difference/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
divide_array_into_arrays_with_max_difference/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
divide_array_into_equal_pairs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
divide_array_into_equal_pairs/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (divideArray [3,2,3,2,2,2])," True (divideArray [3,2,3,2,2,2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (divideArray [1,2,3,4])," False (divideArray [1,2,3,4]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
divide_array_into_equal_pairs/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(true, divideArray(new ArrayList<>(Arrays.asList(3,2,3,2,2,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, divideArray(new ArrayList<>(Arrays.asList(1,2,3,4))));
19
+ }
20
+
21
+ }
divide_array_into_equal_pairs/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
divide_array_into_equal_pairs/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal true (divideArray [3;2;3;2;2;2])
12
+
13
+ let test2 _ = assert_equal false (divideArray [1;2;3;4])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for divideArray" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
divide_array_into_equal_pairs/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.divideArray(List(3,2,3,2,2,2)), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.divideArray(List(1,2,3,4)), false)
10
+ }
11
+
12
+ }
divide_intervals_into_minimum_number_of_groups/.DS_Store ADDED
Binary file (6.15 kB). View file
 
divide_intervals_into_minimum_number_of_groups/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (minGroups [[5,10],[6,8],[1,5],[2,3],[1,10]])," 3 (minGroups [[5,10],[6,8],[1,5],[2,3],[1,10]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minGroups [[1,3],[5,6],[8,10],[11,13]])," 1 (minGroups [[1,3],[5,6],[8,10],[11,13]]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
divide_intervals_into_minimum_number_of_groups/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, minGroups(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,10)),new ArrayList<>(Arrays.asList(6,8)),new ArrayList<>(Arrays.asList(1,5)),new ArrayList<>(Arrays.asList(2,3)),new ArrayList<>(Arrays.asList(1,10))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, minGroups(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(5,6)),new ArrayList<>(Arrays.asList(8,10)),new ArrayList<>(Arrays.asList(11,13))))));
19
+ }
20
+
21
+ }