626394dcaf3d5457e1a7f327907aa2c9c0bb93b638a2bdf566a3b653816c095e
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- minimum_sum_of_mountain_triplets_i/java_tests/Main.java +24 -0
- minimum_sum_of_mountain_triplets_i/meta.json +371 -0
- minimum_sum_of_mountain_triplets_i/ocaml_tests/main.ml +51 -0
- minimum_sum_of_mountain_triplets_i/scala_tests/MySuite.scala +44 -0
- minimum_sum_of_mountain_triplets_ii/haskell_tests/Main.hs +0 -0
- minimum_sum_of_mountain_triplets_ii/java_tests/Main.java +24 -0
- minimum_sum_of_mountain_triplets_ii/meta.json +0 -0
- minimum_sum_of_mountain_triplets_ii/ocaml_tests/main.ml +0 -0
- minimum_sum_of_mountain_triplets_ii/scala_tests/MySuite.scala +0 -0
- minimum_sum_of_squared_difference/.DS_Store +0 -0
- minimum_sum_of_squared_difference/haskell_tests/Main.hs +24 -0
- minimum_sum_of_squared_difference/java_tests/Main.java +21 -0
- minimum_sum_of_squared_difference/meta.json +3 -0
- minimum_sum_of_squared_difference/ocaml_tests/main.ml +26 -0
- minimum_sum_of_squared_difference/scala_tests/MySuite.scala +12 -0
- minimum_sum_of_values_by_dividing_array/haskell_tests/Main.hs +0 -0
- minimum_sum_of_values_by_dividing_array/java_tests/Main.java +25 -0
- minimum_sum_of_values_by_dividing_array/meta.json +0 -0
- minimum_sum_of_values_by_dividing_array/ocaml_tests/main.ml +0 -0
- minimum_sum_of_values_by_dividing_array/scala_tests/MySuite.scala +0 -0
- minimum_swaps_to_group_all_1s_together_ii/.DS_Store +0 -0
- minimum_swaps_to_group_all_1s_together_ii/haskell_tests/Main.hs +27 -0
- minimum_swaps_to_group_all_1s_together_ii/java_tests/Main.java +25 -0
- minimum_swaps_to_group_all_1s_together_ii/meta.json +3 -0
- minimum_swaps_to_group_all_1s_together_ii/ocaml_tests/main.ml +29 -0
- minimum_swaps_to_group_all_1s_together_ii/scala_tests/MySuite.scala +16 -0
- minimum_time_to_break_locks_i/haskell_tests/Main.hs +45 -0
- minimum_time_to_break_locks_i/java_tests/Main.java +21 -0
- minimum_time_to_break_locks_i/meta.json +158 -0
- minimum_time_to_break_locks_i/ocaml_tests/main.ml +50 -0
- minimum_time_to_break_locks_i/scala_tests/MySuite.scala +44 -0
- minimum_time_to_complete_all_tasks/.DS_Store +0 -0
- minimum_time_to_complete_all_tasks/haskell_tests/Main.hs +24 -0
- minimum_time_to_complete_all_tasks/java_tests/Main.java +21 -0
- minimum_time_to_complete_all_tasks/meta.json +0 -0
- minimum_time_to_complete_all_tasks/ocaml_tests/main.ml +26 -0
- minimum_time_to_complete_all_tasks/scala_tests/MySuite.scala +12 -0
- minimum_time_to_complete_trips/.DS_Store +0 -0
- minimum_time_to_complete_trips/haskell_tests/Main.hs +24 -0
- minimum_time_to_complete_trips/java_tests/Main.java +21 -0
- minimum_time_to_complete_trips/meta.json +3 -0
- minimum_time_to_complete_trips/ocaml_tests/main.ml +26 -0
- minimum_time_to_complete_trips/scala_tests/MySuite.scala +12 -0
- minimum_time_to_finish_the_race/.DS_Store +0 -0
- minimum_time_to_finish_the_race/haskell_tests/Main.hs +24 -0
- minimum_time_to_finish_the_race/java_tests/Main.java +21 -0
- minimum_time_to_finish_the_race/meta.json +3 -0
- minimum_time_to_finish_the_race/ocaml_tests/main.ml +26 -0
- minimum_time_to_finish_the_race/scala_tests/MySuite.scala +12 -0
.gitattributes
CHANGED
|
@@ -242,3 +242,7 @@ minimum_rounds_to_complete_all_tasks/meta.json filter=lfs diff=lfs merge=lfs -te
|
|
| 242 |
minimum_score_of_a_path_between_two_cities/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 243 |
minimum_seconds_to_equalize_a_circular_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 244 |
minimum_size_subarray_in_infinite_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
minimum_score_of_a_path_between_two_cities/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 243 |
minimum_seconds_to_equalize_a_circular_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 244 |
minimum_size_subarray_in_infinite_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 245 |
+
minimum_sum_of_squared_difference/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 246 |
+
minimum_swaps_to_group_all_1s_together_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 247 |
+
minimum_time_to_complete_trips/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 248 |
+
minimum_time_to_finish_the_race/meta.json filter=lfs diff=lfs merge=lfs -text
|
minimum_sum_of_mountain_triplets_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(9, minimumSum(Arrays.asList(8,6,1,5,3)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(13, minimumSum(Arrays.asList(5,4,8,7,10,2)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(-1, minimumSum(Arrays.asList(6,5,4,3,4,5)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
minimum_sum_of_mountain_triplets_i/meta.json
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3176,
|
| 3 |
+
"name": "minimum_sum_of_mountain_triplets_i",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i/",
|
| 6 |
+
"date": "2023-10-15 00:00:00",
|
| 7 |
+
"task_description": "You are given a **0-indexed** array `nums` of integers. A triplet of indices `(i, j, k)` is a **mountain** if: `i < j < k` `nums[i] < nums[j]` and `nums[k] < nums[j]` Return _the **minimum possible sum** of a mountain triplet of_ `nums`. _If no such triplet exists, return_ `-1`. **Example 1:** ``` **Input:** nums = [8,6,1,5,3] **Output:** 9 **Explanation:** Triplet (2, 3, 4) is a mountain triplet of sum 9 since: - 2 < 3 < 4 - nums[2] < nums[3] and nums[4] < nums[3] And the sum of this triplet is nums[2] + nums[3] + nums[4] = 9. It can be shown that there are no mountain triplets with a sum of less than 9. ``` **Example 2:** ``` **Input:** nums = [5,4,8,7,10,2] **Output:** 13 **Explanation:** Triplet (1, 3, 5) is a mountain triplet of sum 13 since: - 1 < 3 < 5 - nums[1] < nums[3] and nums[5] < nums[3] And the sum of this triplet is nums[1] + nums[3] + nums[5] = 13. It can be shown that there are no mountain triplets with a sum of less than 13. ``` **Example 3:** ``` **Input:** nums = [6,5,4,3,4,5] **Output:** -1 **Explanation:** It can be shown that there are no mountain triplets in nums. ``` **Constraints:** `3 <= nums.length <= 50` `1 <= nums[i] <= 50`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [8,6,1,5,3]",
|
| 12 |
+
"output": "9 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [5,4,8,7,10,2]",
|
| 17 |
+
"output": "13 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "nums = [6,5,4,3,4,5]",
|
| 22 |
+
"output": "-1 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
7,
|
| 29 |
+
5,
|
| 30 |
+
14,
|
| 31 |
+
12,
|
| 32 |
+
17,
|
| 33 |
+
16,
|
| 34 |
+
49,
|
| 35 |
+
41,
|
| 36 |
+
11,
|
| 37 |
+
47,
|
| 38 |
+
40,
|
| 39 |
+
27,
|
| 40 |
+
33,
|
| 41 |
+
10,
|
| 42 |
+
22,
|
| 43 |
+
48,
|
| 44 |
+
16,
|
| 45 |
+
43,
|
| 46 |
+
33,
|
| 47 |
+
23,
|
| 48 |
+
35,
|
| 49 |
+
46,
|
| 50 |
+
9,
|
| 51 |
+
31,
|
| 52 |
+
5,
|
| 53 |
+
19,
|
| 54 |
+
1,
|
| 55 |
+
44,
|
| 56 |
+
50,
|
| 57 |
+
4,
|
| 58 |
+
20,
|
| 59 |
+
20,
|
| 60 |
+
14,
|
| 61 |
+
4,
|
| 62 |
+
11,
|
| 63 |
+
47,
|
| 64 |
+
27
|
| 65 |
+
],
|
| 66 |
+
"output": 15
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"input": [
|
| 70 |
+
30,
|
| 71 |
+
14,
|
| 72 |
+
27,
|
| 73 |
+
36,
|
| 74 |
+
34,
|
| 75 |
+
37,
|
| 76 |
+
37,
|
| 77 |
+
33,
|
| 78 |
+
25,
|
| 79 |
+
45,
|
| 80 |
+
40,
|
| 81 |
+
3,
|
| 82 |
+
35,
|
| 83 |
+
49,
|
| 84 |
+
24,
|
| 85 |
+
47,
|
| 86 |
+
17,
|
| 87 |
+
45,
|
| 88 |
+
16,
|
| 89 |
+
44,
|
| 90 |
+
32,
|
| 91 |
+
40,
|
| 92 |
+
45,
|
| 93 |
+
42,
|
| 94 |
+
22,
|
| 95 |
+
34,
|
| 96 |
+
46,
|
| 97 |
+
5,
|
| 98 |
+
14,
|
| 99 |
+
21,
|
| 100 |
+
42,
|
| 101 |
+
18,
|
| 102 |
+
4,
|
| 103 |
+
43,
|
| 104 |
+
8,
|
| 105 |
+
38,
|
| 106 |
+
24,
|
| 107 |
+
1,
|
| 108 |
+
41,
|
| 109 |
+
31,
|
| 110 |
+
34,
|
| 111 |
+
45
|
| 112 |
+
],
|
| 113 |
+
"output": 8
|
| 114 |
+
},
|
| 115 |
+
{
|
| 116 |
+
"input": [
|
| 117 |
+
50,
|
| 118 |
+
27,
|
| 119 |
+
45,
|
| 120 |
+
23,
|
| 121 |
+
25,
|
| 122 |
+
19,
|
| 123 |
+
22,
|
| 124 |
+
8,
|
| 125 |
+
21,
|
| 126 |
+
30,
|
| 127 |
+
16,
|
| 128 |
+
15,
|
| 129 |
+
37,
|
| 130 |
+
36,
|
| 131 |
+
22,
|
| 132 |
+
29,
|
| 133 |
+
34,
|
| 134 |
+
4,
|
| 135 |
+
13,
|
| 136 |
+
44,
|
| 137 |
+
30,
|
| 138 |
+
24,
|
| 139 |
+
19
|
| 140 |
+
],
|
| 141 |
+
"output": 27
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"input": [
|
| 145 |
+
6,
|
| 146 |
+
48,
|
| 147 |
+
48,
|
| 148 |
+
13,
|
| 149 |
+
27,
|
| 150 |
+
13,
|
| 151 |
+
18,
|
| 152 |
+
25,
|
| 153 |
+
22,
|
| 154 |
+
39,
|
| 155 |
+
42,
|
| 156 |
+
49,
|
| 157 |
+
8,
|
| 158 |
+
1,
|
| 159 |
+
46,
|
| 160 |
+
5,
|
| 161 |
+
11,
|
| 162 |
+
33,
|
| 163 |
+
16
|
| 164 |
+
],
|
| 165 |
+
"output": 15
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"input": [
|
| 169 |
+
14,
|
| 170 |
+
42,
|
| 171 |
+
6,
|
| 172 |
+
21,
|
| 173 |
+
33,
|
| 174 |
+
25,
|
| 175 |
+
44,
|
| 176 |
+
48,
|
| 177 |
+
33,
|
| 178 |
+
18,
|
| 179 |
+
16,
|
| 180 |
+
21,
|
| 181 |
+
46,
|
| 182 |
+
43,
|
| 183 |
+
11,
|
| 184 |
+
34,
|
| 185 |
+
23,
|
| 186 |
+
36,
|
| 187 |
+
36,
|
| 188 |
+
5,
|
| 189 |
+
25,
|
| 190 |
+
31,
|
| 191 |
+
32,
|
| 192 |
+
4,
|
| 193 |
+
39,
|
| 194 |
+
27,
|
| 195 |
+
35,
|
| 196 |
+
32,
|
| 197 |
+
5,
|
| 198 |
+
42,
|
| 199 |
+
45,
|
| 200 |
+
8,
|
| 201 |
+
47,
|
| 202 |
+
47,
|
| 203 |
+
2,
|
| 204 |
+
6,
|
| 205 |
+
15,
|
| 206 |
+
19,
|
| 207 |
+
43,
|
| 208 |
+
22,
|
| 209 |
+
34,
|
| 210 |
+
44,
|
| 211 |
+
24,
|
| 212 |
+
2,
|
| 213 |
+
12,
|
| 214 |
+
41,
|
| 215 |
+
39,
|
| 216 |
+
50
|
| 217 |
+
],
|
| 218 |
+
"output": 10
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"input": [
|
| 222 |
+
39,
|
| 223 |
+
31,
|
| 224 |
+
2,
|
| 225 |
+
22,
|
| 226 |
+
5,
|
| 227 |
+
36,
|
| 228 |
+
34,
|
| 229 |
+
47,
|
| 230 |
+
50
|
| 231 |
+
],
|
| 232 |
+
"output": 29
|
| 233 |
+
},
|
| 234 |
+
{
|
| 235 |
+
"input": [
|
| 236 |
+
26,
|
| 237 |
+
26,
|
| 238 |
+
11,
|
| 239 |
+
27,
|
| 240 |
+
13,
|
| 241 |
+
22,
|
| 242 |
+
8,
|
| 243 |
+
31,
|
| 244 |
+
1,
|
| 245 |
+
12,
|
| 246 |
+
31,
|
| 247 |
+
31,
|
| 248 |
+
6,
|
| 249 |
+
16,
|
| 250 |
+
37,
|
| 251 |
+
46,
|
| 252 |
+
2,
|
| 253 |
+
27,
|
| 254 |
+
30,
|
| 255 |
+
7
|
| 256 |
+
],
|
| 257 |
+
"output": 9
|
| 258 |
+
},
|
| 259 |
+
{
|
| 260 |
+
"input": [
|
| 261 |
+
2,
|
| 262 |
+
13,
|
| 263 |
+
36,
|
| 264 |
+
22,
|
| 265 |
+
7,
|
| 266 |
+
41,
|
| 267 |
+
4,
|
| 268 |
+
20,
|
| 269 |
+
33,
|
| 270 |
+
27,
|
| 271 |
+
7,
|
| 272 |
+
17,
|
| 273 |
+
15,
|
| 274 |
+
44,
|
| 275 |
+
17,
|
| 276 |
+
26,
|
| 277 |
+
35,
|
| 278 |
+
13,
|
| 279 |
+
7,
|
| 280 |
+
50,
|
| 281 |
+
10,
|
| 282 |
+
41,
|
| 283 |
+
38,
|
| 284 |
+
33,
|
| 285 |
+
43,
|
| 286 |
+
34,
|
| 287 |
+
5,
|
| 288 |
+
23,
|
| 289 |
+
7,
|
| 290 |
+
35,
|
| 291 |
+
10,
|
| 292 |
+
42,
|
| 293 |
+
46,
|
| 294 |
+
7,
|
| 295 |
+
8,
|
| 296 |
+
8,
|
| 297 |
+
11,
|
| 298 |
+
6,
|
| 299 |
+
8,
|
| 300 |
+
22
|
| 301 |
+
],
|
| 302 |
+
"output": 13
|
| 303 |
+
},
|
| 304 |
+
{
|
| 305 |
+
"input": [
|
| 306 |
+
46,
|
| 307 |
+
45,
|
| 308 |
+
46,
|
| 309 |
+
41,
|
| 310 |
+
34,
|
| 311 |
+
23,
|
| 312 |
+
46,
|
| 313 |
+
1,
|
| 314 |
+
8,
|
| 315 |
+
48,
|
| 316 |
+
26,
|
| 317 |
+
3,
|
| 318 |
+
49,
|
| 319 |
+
43,
|
| 320 |
+
42,
|
| 321 |
+
16,
|
| 322 |
+
1,
|
| 323 |
+
22,
|
| 324 |
+
5,
|
| 325 |
+
14,
|
| 326 |
+
24,
|
| 327 |
+
41,
|
| 328 |
+
39,
|
| 329 |
+
36,
|
| 330 |
+
20,
|
| 331 |
+
30,
|
| 332 |
+
1,
|
| 333 |
+
8,
|
| 334 |
+
50,
|
| 335 |
+
37,
|
| 336 |
+
12,
|
| 337 |
+
41,
|
| 338 |
+
26,
|
| 339 |
+
1,
|
| 340 |
+
20
|
| 341 |
+
],
|
| 342 |
+
"output": 5
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"input": [
|
| 346 |
+
32,
|
| 347 |
+
29,
|
| 348 |
+
21,
|
| 349 |
+
3,
|
| 350 |
+
44,
|
| 351 |
+
28,
|
| 352 |
+
9,
|
| 353 |
+
9,
|
| 354 |
+
34,
|
| 355 |
+
50,
|
| 356 |
+
34,
|
| 357 |
+
39,
|
| 358 |
+
25,
|
| 359 |
+
38,
|
| 360 |
+
43,
|
| 361 |
+
48
|
| 362 |
+
],
|
| 363 |
+
"output": 40
|
| 364 |
+
}
|
| 365 |
+
],
|
| 366 |
+
"haskell_template": "minimumSum :: [Int] -> Int\nminimumSum nums ",
|
| 367 |
+
"ocaml_template": "let minimumSum (nums: int list) : int = ",
|
| 368 |
+
"scala_template": "def minimumSum(nums: List[Int]): Int = { \n \n}",
|
| 369 |
+
"java_template": "class Solution {\n public int minimumSum(int[] nums) {\n \n }\n}",
|
| 370 |
+
"python_template": "class Solution(object):\n def minimumSum(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
|
| 371 |
+
}
|
minimum_sum_of_mountain_triplets_i/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let minimumSum (nums: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 9 (minimumSum [8;6;1;5;3])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 13 (minimumSum [5;4;8;7;10;2])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal (-1) (minimumSum [6;5;4;3;4;5])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal (-1) (minimumSum [7; 5; 14; 12; 17; 16; 49; 41; 11; 47; 40; 27; 33; 10; 22; 48; 16; 43; 33; 23; 35; 46; 9; 31; 5; 19; 1; 44; 50; 4; 20; 20; 14; 4; 11; 47; 27])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal (-1) (minimumSum [30; 14; 27; 36; 34; 37; 37; 33; 25; 45; 40; 3; 35; 49; 24; 47; 17; 45; 16; 44; 32; 40; 45; 42; 22; 34; 46; 5; 14; 21; 42; 18; 4; 43; 8; 38; 24; 1; 41; 31; 34; 45])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal (-1) (minimumSum [50; 27; 45; 23; 25; 19; 22; 8; 21; 30; 16; 15; 37; 36; 22; 29; 34; 4; 13; 44; 30; 24; 19])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal (-1) (minimumSum [6; 48; 48; 13; 27; 13; 18; 25; 22; 39; 42; 49; 8; 1; 46; 5; 11; 33; 16])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal (-1) (minimumSum [14; 42; 6; 21; 33; 25; 44; 48; 33; 18; 16; 21; 46; 43; 11; 34; 23; 36; 36; 5; 25; 31; 32; 4; 39; 27; 35; 32; 5; 42; 45; 8; 47; 47; 2; 6; 15; 19; 43; 22; 34; 44; 24; 2; 12; 41; 39; 50])
|
| 27 |
+
|
| 28 |
+
let test9 _ = assert_equal (-1) (minimumSum [39; 31; 2; 22; 5; 36; 34; 47; 50])
|
| 29 |
+
|
| 30 |
+
let test10 _ = assert_equal (-1) (minimumSum [26; 26; 11; 27; 13; 22; 8; 31; 1; 12; 31; 31; 6; 16; 37; 46; 2; 27; 30; 7])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
(* Grouping test cases *)
|
| 34 |
+
let suite = "Test Suite for minimumSum" >::: [
|
| 35 |
+
|
| 36 |
+
"test1" >:: test1;
|
| 37 |
+
"test2" >:: test2;
|
| 38 |
+
"test3" >:: test3;
|
| 39 |
+
"test4" >:: test4;
|
| 40 |
+
"test5" >:: test5;
|
| 41 |
+
"test6" >:: test6;
|
| 42 |
+
"test7" >:: test7;
|
| 43 |
+
"test8" >:: test8;
|
| 44 |
+
"test9" >:: test9;
|
| 45 |
+
"test10" >:: test10;
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
(* Running the tests *)
|
| 50 |
+
let () = run_test_tt_main suite
|
| 51 |
+
end
|
minimum_sum_of_mountain_triplets_i/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumSum(List(8,6,1,5,3)), 9)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumSum(List(5,4,8,7,10,2)), 13)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.minimumSum(List(6,5,4,3,4,5)), -1)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.minimumSum(7,5,14,12,17,16,49,41,11,47,40,27,33,10,22,48,16,43,33,23,35,46,9,31,5,19,1,44,50,4,20,20,14,4,11,47,27), 15)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.minimumSum(30,14,27,36,34,37,37,33,25,45,40,3,35,49,24,47,17,45,16,44,32,40,45,42,22,34,46,5,14,21,42,18,4,43,8,38,24,1,41,31,34,45), 8)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.minimumSum(50,27,45,23,25,19,22,8,21,30,16,15,37,36,22,29,34,4,13,44,30,24,19), 27)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.minimumSum(6,48,48,13,27,13,18,25,22,39,42,49,8,1,46,5,11,33,16), 15)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.minimumSum(14,42,6,21,33,25,44,48,33,18,16,21,46,43,11,34,23,36,36,5,25,31,32,4,39,27,35,32,5,42,45,8,47,47,2,6,15,19,43,22,34,44,24,2,12,41,39,50), 10)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.minimumSum(39,31,2,22,5,36,34,47,50), 29)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.minimumSum(26,26,11,27,13,22,8,31,1,12,31,31,6,16,37,46,2,27,30,7), 9)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
minimum_sum_of_mountain_triplets_ii/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_mountain_triplets_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(9, minimumSum(Arrays.asList(8,6,1,5,3)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(13, minimumSum(Arrays.asList(5,4,8,7,10,2)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(-1, minimumSum(Arrays.asList(6,5,4,3,4,5)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
minimum_sum_of_mountain_triplets_ii/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_mountain_triplets_ii/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_mountain_triplets_ii/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_squared_difference/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_sum_of_squared_difference/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 (minSumSquareDiff [1,2,3,4] [2,10,20,19] 0 0)," 579 (minSumSquareDiff [1,2,3,4] [2,10,20,19] 0 0))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minSumSquareDiff [1,4,10,12] [5,8,6,9] 1 1)," 43 (minSumSquareDiff [1,4,10,12] [5,8,6,9] 1 1))
|
| 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
|
minimum_sum_of_squared_difference/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(579, minSumSquareDiff(new ArrayList<>(Arrays.asList(1,2,3,4)), new ArrayList<>(Arrays.asList(2,10,20,19)), 0, 0));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(43, minSumSquareDiff(new ArrayList<>(Arrays.asList(1,4,10,12)), new ArrayList<>(Arrays.asList(5,8,6,9)), 1, 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_sum_of_squared_difference/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:391cd0f351b3e1e6d1c073da6d8e3e1f2e07e00cde0cbf27c54c1b8cc39d9a47
|
| 3 |
+
size 41597826
|
minimum_sum_of_squared_difference/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 579 (minSumSquareDiff [1;2;3;4] [2;10;20;19] 0 0)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 43 (minSumSquareDiff [1;4;10;12] [5;8;6;9] 1 1)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for minSumSquareDiff" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_sum_of_squared_difference/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minSumSquareDiff(List(1,2,3,4),List(2,10,20,19),0,0), 579)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minSumSquareDiff(List(1,4,10,12),List(5,8,6,9),1,1), 43)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_sum_of_values_by_dividing_array/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_values_by_dividing_array/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(12, minimumValueSum(new ArrayList<>(Arrays.asList(1,4,3,3,2)), new ArrayList<>(Arrays.asList(0,3,3,2))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(17, minimumValueSum(new ArrayList<>(Arrays.asList(2,3,5,7,7,7,5)), new ArrayList<>(Arrays.asList(0,7,5))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(-1, minimumValueSum(new ArrayList<>(Arrays.asList(1,2,3,4)), new ArrayList<>(Arrays.asList(2))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
minimum_sum_of_values_by_dividing_array/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_values_by_dividing_array/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_sum_of_values_by_dividing_array/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_swaps_to_group_all_1s_together_ii/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_swaps_to_group_all_1s_together_ii/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 (minSwaps [0,1,0,1,1,0,0])," 1 (minSwaps [0,1,0,1,1,0,0]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minSwaps [0,1,1,1,0,0,1,1,0])," 2 (minSwaps [0,1,1,1,0,0,1,1,0]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (minSwaps [1,1,0,0,1])," 0 (minSwaps [1,1,0,0,1]))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
-- Grouping test cases
|
| 22 |
+
tests :: Test
|
| 23 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
|
| 24 |
+
|
| 25 |
+
-- Running the tests
|
| 26 |
+
main :: IO Counts
|
| 27 |
+
main = runTestTT tests
|
minimum_swaps_to_group_all_1s_together_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(1, minSwaps(new ArrayList<>(Arrays.asList(0,1,0,1,1,0,0))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, minSwaps(new ArrayList<>(Arrays.asList(0,1,1,1,0,0,1,1,0))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, minSwaps(new ArrayList<>(Arrays.asList(1,1,0,0,1))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
minimum_swaps_to_group_all_1s_together_ii/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14dcb28aa9fefcf04933e5b134b45e21dd2897088f7526c1d1e53f7efb3bd544
|
| 3 |
+
size 11501829
|
minimum_swaps_to_group_all_1s_together_ii/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 (minSwaps [0;1;0;1;1;0;0])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (minSwaps [0;1;1;1;0;0;1;1;0])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 0 (minSwaps [1;1;0;0;1])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for minSwaps" >::: [
|
| 20 |
+
|
| 21 |
+
"test1" >:: test1;
|
| 22 |
+
"test2" >:: test2;
|
| 23 |
+
"test3" >:: test3;
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Running the tests *)
|
| 28 |
+
let () = run_test_tt_main suite
|
| 29 |
+
end
|
minimum_swaps_to_group_all_1s_together_ii/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minSwaps(List(0,1,0,1,1,0,0)), 1)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minSwaps(List(0,1,1,1,0,0,1,1,0)), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.minSwaps(List(1,1,0,0,1)), 0)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
minimum_time_to_break_locks_i/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 (findMinimumTime [3,4,1] 1)," 4 (findMinimumTime [3,4,1] 1))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (findMinimumTime [2,5,4] 2)," 5 (findMinimumTime [2,5,4] 2))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (findMinimumTime [137378, 881675, 832554, 792714, 582715, 957086, 55824] 10)," 174919 (findMinimumTime [137378, 881675, 832554, 792714, 582715, 957086, 55824] 10))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (findMinimumTime [307658, 586884, 872424, 781340, 571556] 7)," 483829 (findMinimumTime [307658, 586884, 872424, 781340, 571556] 7))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (findMinimumTime [341577, 233634, 669815, 36908] 10)," 96021 (findMinimumTime [341577, 233634, 669815, 36908] 10))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (findMinimumTime [630856, 383599, 544692, 621165, 419087, 83758] 6)," 244662 (findMinimumTime [630856, 383599, 544692, 621165, 419087, 83758] 6))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (findMinimumTime [423390, 269329, 235002, 274601] 7)," 306221 (findMinimumTime [423390, 269329, 235002, 274601] 7))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (findMinimumTime [949077, 571566, 186726] 6)," 341385 (findMinimumTime [949077, 571566, 186726] 6))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (findMinimumTime [898445, 876951, 491188, 629389, 800933, 982853] 5)," 804297 (findMinimumTime [898445, 876951, 491188, 629389, 800933, 982853] 5))
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
-- Grouping test cases
|
| 40 |
+
tests :: Test
|
| 41 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
|
| 42 |
+
|
| 43 |
+
-- Running the tests
|
| 44 |
+
main :: IO Counts
|
| 45 |
+
main = runTestTT tests
|
minimum_time_to_break_locks_i/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(4, findMinimumTime(new ArrayList<>(Arrays.asList(3,4,1)), 1));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(5, findMinimumTime(new ArrayList<>(Arrays.asList(2,5,4)), 2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_time_to_break_locks_i/meta.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3649,
|
| 3 |
+
"name": "minimum_time_to_break_locks_i",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/minimum-time-to-break-locks-i/",
|
| 6 |
+
"date": "2024-11-23 00:00:00",
|
| 7 |
+
"task_description": "Bob is stuck in a dungeon and must break `n` locks, each requiring some amount of **energy** to break. The required energy for each lock is stored in an array called `strength` where `strength[i]` indicates the energy needed to break the `ith` lock. To break a lock, Bob uses a sword with the following characteristics: The initial energy of the sword is 0. The initial factor `x` by which the energy of the sword increases is 1. Every minute, the energy of the sword increases by the current factor `x`. To break the `ith` lock, the energy of the sword must reach **at least** `strength[i]`. After breaking a lock, the energy of the sword resets to 0, and the factor `x` increases by a given value `k`. Your task is to determine the **minimum** time in minutes required for Bob to break all `n` locks and escape the dungeon. Return the **minimum **time required for Bob to break all `n` locks. **Example 1:** **Input:** strength = [3,4,1], k = 1 **Output:** 4 **Explanation:** Time Energy x Action Updated x 0 0 1 Nothing 1 1 1 1 Break 3rd Lock 2 2 2 2 Nothing 2 3 4 2 Break 2nd Lock 3 4 3 3 Break 1st Lock 3 The locks cannot be broken in less than 4 minutes; thus, the answer is 4. **Example 2:** **Input:** strength = [2,5,4], k = 2 **Output:** 5 **Explanation:** Time Energy x Action Updated x 0 0 1 Nothing 1 1 1 1 Nothing 1 2 2 1 Break 1st Lock 3 3 3 3 Nothing 3 4 6 3 Break 2nd Lock 5 5 5 5 Break 3rd Lock 7 The locks cannot be broken in less than 5 minutes; thus, the answer is 5. **Constraints:** `n == strength.length` `1 <= n <= 8` `1 <= K <= 10` `1 <= strength[i] <= 106`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "strength = [3,4,1], k = 1",
|
| 12 |
+
"output": "4 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "strength = [2,5,4], k = 2",
|
| 17 |
+
"output": "5 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
137378,
|
| 25 |
+
881675,
|
| 26 |
+
832554,
|
| 27 |
+
792714,
|
| 28 |
+
582715,
|
| 29 |
+
957086,
|
| 30 |
+
55824
|
| 31 |
+
],
|
| 32 |
+
10
|
| 33 |
+
],
|
| 34 |
+
"output": 174919
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"input": [
|
| 38 |
+
[
|
| 39 |
+
307658,
|
| 40 |
+
586884,
|
| 41 |
+
872424,
|
| 42 |
+
781340,
|
| 43 |
+
571556
|
| 44 |
+
],
|
| 45 |
+
7
|
| 46 |
+
],
|
| 47 |
+
"output": 483829
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"input": [
|
| 51 |
+
[
|
| 52 |
+
341577,
|
| 53 |
+
233634,
|
| 54 |
+
669815,
|
| 55 |
+
36908
|
| 56 |
+
],
|
| 57 |
+
10
|
| 58 |
+
],
|
| 59 |
+
"output": 96021
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
[
|
| 64 |
+
630856,
|
| 65 |
+
383599,
|
| 66 |
+
544692,
|
| 67 |
+
621165,
|
| 68 |
+
419087,
|
| 69 |
+
83758
|
| 70 |
+
],
|
| 71 |
+
6
|
| 72 |
+
],
|
| 73 |
+
"output": 244662
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
[
|
| 78 |
+
423390,
|
| 79 |
+
269329,
|
| 80 |
+
235002,
|
| 81 |
+
274601
|
| 82 |
+
],
|
| 83 |
+
7
|
| 84 |
+
],
|
| 85 |
+
"output": 306221
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"input": [
|
| 89 |
+
[
|
| 90 |
+
949077,
|
| 91 |
+
571566,
|
| 92 |
+
186726
|
| 93 |
+
],
|
| 94 |
+
6
|
| 95 |
+
],
|
| 96 |
+
"output": 341385
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"input": [
|
| 100 |
+
[
|
| 101 |
+
898445,
|
| 102 |
+
876951,
|
| 103 |
+
491188,
|
| 104 |
+
629389,
|
| 105 |
+
800933,
|
| 106 |
+
982853
|
| 107 |
+
],
|
| 108 |
+
5
|
| 109 |
+
],
|
| 110 |
+
"output": 804297
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"input": [
|
| 114 |
+
[
|
| 115 |
+
386461,
|
| 116 |
+
647430,
|
| 117 |
+
256210,
|
| 118 |
+
483105,
|
| 119 |
+
777989,
|
| 120 |
+
516737,
|
| 121 |
+
434168
|
| 122 |
+
],
|
| 123 |
+
5
|
| 124 |
+
],
|
| 125 |
+
"output": 464892
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"input": [
|
| 129 |
+
[
|
| 130 |
+
963681,
|
| 131 |
+
987219,
|
| 132 |
+
79662
|
| 133 |
+
],
|
| 134 |
+
5
|
| 135 |
+
],
|
| 136 |
+
"output": 330024
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"input": [
|
| 140 |
+
[
|
| 141 |
+
101667,
|
| 142 |
+
914911,
|
| 143 |
+
65765,
|
| 144 |
+
142139,
|
| 145 |
+
603446,
|
| 146 |
+
726
|
| 147 |
+
],
|
| 148 |
+
8
|
| 149 |
+
],
|
| 150 |
+
"output": 60303
|
| 151 |
+
}
|
| 152 |
+
],
|
| 153 |
+
"haskell_template": "findMinimumTime :: [Int] -> Int -> Int\nfindMinimumTime strength k ",
|
| 154 |
+
"ocaml_template": "let findMinimumTime (strength: int list) (k: int) : int = ",
|
| 155 |
+
"scala_template": "def findMinimumTime(strength: List[Int],k: Int): Int = { \n \n}",
|
| 156 |
+
"java_template": "class Solution {\n public int findMinimumTime(List<Integer> strength, int k) {\n \n }\n}",
|
| 157 |
+
"python_template": "class Solution(object):\n def findMinimumTime(self, strength, k):\n \"\"\"\n :type strength: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
|
| 158 |
+
}
|
minimum_time_to_break_locks_i/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 4 (findMinimumTime [3;4;1] 1)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 5 (findMinimumTime [2;5;4] 2)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 174919 (findMinimumTime [137378; 881675; 832554; 792714; 582715; 957086; 55824] 10)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 483829 (findMinimumTime [307658; 586884; 872424; 781340; 571556] 7)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 96021 (findMinimumTime [341577; 233634; 669815; 36908] 10)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 244662 (findMinimumTime [630856; 383599; 544692; 621165; 419087; 83758] 6)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 306221 (findMinimumTime [423390; 269329; 235002; 274601] 7)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 341385 (findMinimumTime [949077; 571566; 186726] 6)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 804297 (findMinimumTime [898445; 876951; 491188; 629389; 800933; 982853] 5)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 464892 (findMinimumTime [386461; 647430; 256210; 483105; 777989; 516737; 434168] 5)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for findMinimumTime" >::: [
|
| 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
|
minimum_time_to_break_locks_i/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.findMinimumTime(List(3,4,1),1), 4)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.findMinimumTime(List(2,5,4),2), 5)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.findMinimumTime(List(137378, 881675, 832554, 792714, 582715, 957086, 55824),10), 174919)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.findMinimumTime(List(307658, 586884, 872424, 781340, 571556),7), 483829)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.findMinimumTime(List(341577, 233634, 669815, 36908),10), 96021)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.findMinimumTime(List(630856, 383599, 544692, 621165, 419087, 83758),6), 244662)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.findMinimumTime(List(423390, 269329, 235002, 274601),7), 306221)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.findMinimumTime(List(949077, 571566, 186726),6), 341385)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.findMinimumTime(List(898445, 876951, 491188, 629389, 800933, 982853),5), 804297)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.findMinimumTime(List(386461, 647430, 256210, 483105, 777989, 516737, 434168),5), 464892)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
minimum_time_to_complete_all_tasks/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_time_to_complete_all_tasks/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 (findMinimumTime [[2,3,1],[4,5,1],[1,5,2]])," 2 (findMinimumTime [[2,3,1],[4,5,1],[1,5,2]]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (findMinimumTime [[1,3,2],[2,5,3],[5,6,2]])," 4 (findMinimumTime [[1,3,2],[2,5,3],[5,6,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
|
minimum_time_to_complete_all_tasks/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(2, findMinimumTime(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,3,1)),new ArrayList<>(Arrays.asList(4,5,1)),new ArrayList<>(Arrays.asList(1,5,2))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(4, findMinimumTime(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3,2)),new ArrayList<>(Arrays.asList(2,5,3)),new ArrayList<>(Arrays.asList(5,6,2))))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_time_to_complete_all_tasks/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
minimum_time_to_complete_all_tasks/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 2 (findMinimumTime [[2;3;1];[4;5;1];[1;5;2]])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 4 (findMinimumTime [[1;3;2];[2;5;3];[5;6;2]])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for findMinimumTime" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_time_to_complete_all_tasks/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.findMinimumTime(List(List(2,3,1),List(4,5,1),List(1,5,2))), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.findMinimumTime(List(List(1,3,2),List(2,5,3),List(5,6,2))), 4)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_time_to_complete_trips/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_time_to_complete_trips/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 (minimumTime [1,2,3] 5)," 3 (minimumTime [1,2,3] 5))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minimumTime [2] 1)," 2 (minimumTime [2] 1))
|
| 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
|
minimum_time_to_complete_trips/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, minimumTime(new ArrayList<>(Arrays.asList(1,2,3)), 5));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, minimumTime(new ArrayList<>(Arrays.asList(2)), 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_time_to_complete_trips/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a9ff8d9b101cc290e3436f740d68ac4366fa60da0575c61b58d7462b62b7b44
|
| 3 |
+
size 14111266
|
minimum_time_to_complete_trips/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 3 (minimumTime [1;2;3] 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (minimumTime [2] 1)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for minimumTime" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_time_to_complete_trips/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumTime(List(1,2,3),5), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumTime(List(2),1), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
minimum_time_to_finish_the_race/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
minimum_time_to_finish_the_race/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 (minimumFinishTime [[2,3],[3,4]] 5 4)," 21 (minimumFinishTime [[2,3],[3,4]] 5 4))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (minimumFinishTime [[1,10],[2,2],[3,4]] 6 5)," 25 (minimumFinishTime [[1,10],[2,2],[3,4]] 6 5))
|
| 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
|
minimum_time_to_finish_the_race/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(21, minimumFinishTime(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,3)),new ArrayList<>(Arrays.asList(3,4)))), 5, 4));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(25, minimumFinishTime(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,10)),new ArrayList<>(Arrays.asList(2,2)),new ArrayList<>(Arrays.asList(3,4)))), 6, 5));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
minimum_time_to_finish_the_race/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:713c11d5c938cd8951ac2ed9e83dcc11bbe1f9d474a7e940b59fc62829333a1e
|
| 3 |
+
size 57503075
|
minimum_time_to_finish_the_race/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 21 (minimumFinishTime [[2;3];[3;4]] 5 4)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 25 (minimumFinishTime [[1;10];[2;2];[3;4]] 6 5)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for minimumFinishTime" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
minimum_time_to_finish_the_race/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.minimumFinishTime(List(List(2,3),List(3,4)),5,4), 21)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.minimumFinishTime(List(List(1,10),List(2,2),List(3,4)),6,5), 25)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|