DatasetRepo commited on
Commit
de08496
·
verified ·
1 Parent(s): 541d05e

2ff8330bfd74005b3b7a257ffd0af75b0a960582de7112aa72eb30a11e704951

Browse files
Files changed (50) hide show
  1. minimum_array_sum/scala_tests/MySuite.scala +44 -0
  2. minimum_average_difference/.DS_Store +0 -0
  3. minimum_average_difference/haskell_tests/Main.hs +24 -0
  4. minimum_average_difference/java_tests/Main.java +21 -0
  5. minimum_average_difference/meta.json +0 -0
  6. minimum_average_difference/ocaml_tests/main.ml +26 -0
  7. minimum_average_difference/scala_tests/MySuite.scala +12 -0
  8. minimum_average_of_smallest_and_largest_elements/haskell_tests/Main.hs +47 -0
  9. minimum_average_of_smallest_and_largest_elements/java_tests/Main.java +24 -0
  10. minimum_average_of_smallest_and_largest_elements/meta.json +354 -0
  11. minimum_average_of_smallest_and_largest_elements/ocaml_tests/main.ml +51 -0
  12. minimum_average_of_smallest_and_largest_elements/scala_tests/MySuite.scala +44 -0
  13. minimum_bit_flips_to_convert_number/.DS_Store +0 -0
  14. minimum_bit_flips_to_convert_number/haskell_tests/Main.hs +24 -0
  15. minimum_bit_flips_to_convert_number/java_tests/Main.java +21 -0
  16. minimum_bit_flips_to_convert_number/meta.json +97 -0
  17. minimum_bit_flips_to_convert_number/ocaml_tests/main.ml +26 -0
  18. minimum_bit_flips_to_convert_number/scala_tests/MySuite.scala +12 -0
  19. minimum_changes_to_make_k_semi_palindromes/.DS_Store +0 -0
  20. minimum_changes_to_make_k_semi_palindromes/haskell_tests/Main.hs +27 -0
  21. minimum_changes_to_make_k_semi_palindromes/java_tests/Main.java +25 -0
  22. minimum_changes_to_make_k_semi_palindromes/meta.json +102 -0
  23. minimum_changes_to_make_k_semi_palindromes/ocaml_tests/main.ml +29 -0
  24. minimum_changes_to_make_k_semi_palindromes/scala_tests/MySuite.scala +16 -0
  25. minimum_common_value/haskell_tests/Main.hs +45 -0
  26. minimum_common_value/java_tests/Main.java +21 -0
  27. minimum_common_value/meta.json +1153 -0
  28. minimum_common_value/ocaml_tests/main.ml +50 -0
  29. minimum_common_value/scala_tests/MySuite.scala +44 -0
  30. minimum_consecutive_cards_to_pick_up/.DS_Store +0 -0
  31. minimum_consecutive_cards_to_pick_up/haskell_tests/Main.hs +24 -0
  32. minimum_consecutive_cards_to_pick_up/java_tests/Main.java +21 -0
  33. minimum_consecutive_cards_to_pick_up/meta.json +0 -0
  34. minimum_consecutive_cards_to_pick_up/ocaml_tests/main.ml +26 -0
  35. minimum_consecutive_cards_to_pick_up/scala_tests/MySuite.scala +12 -0
  36. minimum_cost_for_cutting_cake_i/haskell_tests/Main.hs +45 -0
  37. minimum_cost_for_cutting_cake_i/java_tests/Main.java +21 -0
  38. minimum_cost_for_cutting_cake_i/meta.json +117 -0
  39. minimum_cost_for_cutting_cake_i/ocaml_tests/main.ml +50 -0
  40. minimum_cost_for_cutting_cake_i/scala_tests/MySuite.scala +44 -0
  41. minimum_cost_for_cutting_cake_ii/haskell_tests/Main.hs +45 -0
  42. minimum_cost_for_cutting_cake_ii/java_tests/Main.java +21 -0
  43. minimum_cost_for_cutting_cake_ii/meta.json +117 -0
  44. minimum_cost_for_cutting_cake_ii/ocaml_tests/main.ml +50 -0
  45. minimum_cost_for_cutting_cake_ii/scala_tests/MySuite.scala +44 -0
  46. minimum_cost_good_caption/haskell_tests/Main.hs +29 -0
  47. minimum_cost_good_caption/java_tests/Main.java +24 -0
  48. minimum_cost_good_caption/meta.json +31 -0
  49. minimum_cost_good_caption/ocaml_tests/main.ml +30 -0
  50. minimum_cost_good_caption/scala_tests/MySuite.scala +16 -0
minimum_array_sum/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minArraySum(List(2,8,3,19,3),3,1,1), 23)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minArraySum(List(2,4,3),3,2,1), 3)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minArraySum(List(0, 6, 8, 16, 17, 13, 17, 18, 20, 20, 20, 21, 34, 35, 5, 6, 12, 16, 16, 16),73,11,11), 316)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minArraySum(List(2, 3, 6, 8, 8, 8, 9, 10, 13, 14, 15, 16, 16, 18, 19, 22, 23, 24, 25, 27, 27, 27, 27, 28, 30, 35, 35, 37, 37, 38, 39, 44, 46, 23, 24, 24, 25, 25, 26, 28, 28, 28, 28, 29, 29, 29, 29, 30, 31, 31, 33, 34, 34, 34, 35, 35, 36, 36, 38, 39, 39, 42, 43, 1, 2, 2, 4, 5, 7, 8, 8, 12, 12, 14, 17, 18, 18),87,30,57), 1809)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minArraySum(List(0, 0, 0, 1, 3, 3, 4, 5, 5, 7, 10, 11, 12, 14, 15, 17, 18, 9, 10, 10, 12, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 19, 1, 1, 2, 3, 22, 23, 23, 24, 24, 24, 24, 25, 25, 26, 27, 27, 29, 29, 31, 31, 31, 31, 33, 33, 33, 34, 34, 36, 37, 37, 38, 38, 38, 39, 39, 39, 0, 0, 1, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 9, 10, 10, 10, 11, 11, 12, 12, 12),40,76,33), 1510)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minArraySum(List(5, 5, 4, 5, 7, 8, 9, 12, 13, 14, 16, 18, 19, 19, 22, 23, 24, 24, 26, 27, 28, 28, 29, 30, 34, 36, 37, 37, 41, 42, 42, 45, 46, 48, 3, 3, 4, 4),98,35,10), 837)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minArraySum(List(4, 13, 14, 17, 18, 21, 24, 25, 1, 2, 4, 7, 37, 37, 41, 43, 43, 53, 54, 60, 63, 69, 76, 77, 81, 84, 84, 85, 85, 87, 89, 89, 92, 96, 96),26,0,4), 1771)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minArraySum(List(16, 33, 83, 90, 101),12,0,2), 323)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minArraySum(List(2, 3, 3, 7, 8, 8, 8, 10, 7, 7, 8, 8, 12, 14, 15, 15, 16, 17, 21, 23, 25, 26, 26, 27, 28, 28, 28, 28, 28, 29, 31, 31, 35, 36, 37, 37, 37, 41, 41, 42, 42, 42, 45, 47, 48, 49, 51, 22, 22, 23),30,42,3), 1244)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minArraySum(List(2, 3, 4, 5, 6, 6, 7, 8, 8, 8, 9, 10, 12, 12, 13, 13, 13, 15, 16, 17, 17, 0, 1, 2, 2, 5, 6, 7, 8, 9, 9, 10, 10, 11, 11, 11, 12, 13, 15, 16, 17, 0, 0, 2, 2, 2, 2, 3, 4, 6, 7, 8, 8, 10, 10, 11, 12, 12, 13, 14, 16, 16, 16),35,62,43), 553)
42
+ }
43
+
44
+ }
minimum_average_difference/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_average_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 (minimumAverageDifference [2,5,3,9,5,3])," 3 (minimumAverageDifference [2,5,3,9,5,3]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumAverageDifference [0])," 0 (minimumAverageDifference [0]))
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_average_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(3, minimumAverageDifference(new ArrayList<>(Arrays.asList(2,5,3,9,5,3))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, minimumAverageDifference(new ArrayList<>(Arrays.asList(0))));
19
+ }
20
+
21
+ }
minimum_average_difference/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_average_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 3 (minimumAverageDifference [2;5;3;9;5;3])
12
+
13
+ let test2 _ = assert_equal 0 (minimumAverageDifference [0])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimumAverageDifference" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimum_average_difference/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumAverageDifference(List(2,5,3,9,5,3)), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumAverageDifference(List(0)), 0)
10
+ }
11
+
12
+ }
minimum_average_of_smallest_and_largest_elements/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimumAverage :: [Int] -> Float
7
+ minimumAverage nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimumAverage [7,8,3,4,15,13,4,1])," 5.5 (minimumAverage [7,8,3,4,15,13,4,1]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimumAverage [1,9,8,3,10,5])," 5.5 (minimumAverage [1,9,8,3,10,5]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimumAverage [1,2,3,7,8,9])," 5.0 (minimumAverage [1,2,3,7,8,9]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimumAverage [10, 11, 15, 22, 22, 24])," 16.5 (minimumAverage [10, 11, 15, 22, 22, 24]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimumAverage [1, 1, 4, 5, 9, 11, 11, 12, 12, 13, 14, 15, 18, 20, 20, 21, 21, 25, 31, 33, 36, 37, 39, 40, 44, 45, 46, 48, 48, 49, 50, 50])," 21.0 (minimumAverage [1, 1, 4, 5, 9, 11, 11, 12, 12, 13, 14, 15, 18, 20, 20, 21, 21, 25, 31, 33, 36, 37, 39, 40, 44, 45, 46, 48, 48, 49, 50, 50]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimumAverage [2, 6, 6, 9, 9, 16, 18, 23, 26, 28, 29, 31, 31, 34, 36, 37, 45, 48])," 21.5 (minimumAverage [2, 6, 6, 9, 9, 16, 18, 23, 26, 28, 29, 31, 31, 34, 36, 37, 45, 48]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimumAverage [1, 5, 6, 7, 8, 9, 10, 10, 11, 15, 19, 20, 20, 21, 29, 30, 31, 32, 33, 36, 37, 39, 40, 41, 46, 48])," 20.5 (minimumAverage [1, 5, 6, 7, 8, 9, 10, 10, 11, 15, 19, 20, 20, 21, 29, 30, 31, 32, 33, 36, 37, 39, 40, 41, 46, 48]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (minimumAverage [5, 5, 37, 43, 43, 50])," 24.0 (minimumAverage [5, 5, 37, 43, 43, 50]))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (minimumAverage [1, 2, 3, 3, 3, 3, 4, 6, 6, 7, 7, 7, 8, 11, 15, 16, 20, 20, 21, 22, 22, 26, 30, 31, 31, 36, 36, 37, 37, 38, 38, 39, 40, 42, 42, 42, 49, 49, 50, 50])," 22.0 (minimumAverage [1, 2, 3, 3, 3, 3, 4, 6, 6, 7, 7, 7, 8, 11, 15, 16, 20, 20, 21, 22, 22, 26, 30, 31, 31, 36, 36, 37, 37, 38, 38, 39, 40, 42, 42, 42, 49, 49, 50, 50]))
39
+
40
+
41
+ -- Grouping test cases
42
+ tests :: Test
43
+ 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]
44
+
45
+ -- Running the tests
46
+ main :: IO Counts
47
+ main = runTestTT tests
minimum_average_of_smallest_and_largest_elements/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(5.5, minimumAverage(Arrays.asList(7,8,3,4,15,13,4,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(5.5, minimumAverage(Arrays.asList(1,9,8,3,10,5)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(5.0, minimumAverage(Arrays.asList(1,2,3,7,8,9)));
22
+ }
23
+
24
+ }
minimum_average_of_smallest_and_largest_elements/meta.json ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3471,
3
+ "name": "minimum_average_of_smallest_and_largest_elements",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/",
6
+ "date": "2024-06-16 00:00:00",
7
+ "task_description": "You have an array of floating point numbers `averages` which is initially empty. You are given an array `nums` of `n` integers where `n` is even. You repeat the following procedure `n / 2` times: Remove the **smallest** element, `minElement`, and the **largest** element `maxElement`, from `nums`. Add `(minElement + maxElement) / 2` to `averages`. Return the **minimum** element in `averages`. **Example 1:** **Input:** nums = [7,8,3,4,15,13,4,1] **Output:** 5.5 **Explanation:** step nums averages 0 [7,8,3,4,15,13,4,1] [] 1 [7,8,3,4,13,4] [8] 2 [7,8,4,4] [8,8] 3 [7,4] [8,8,6] 4 [] [8,8,6,5.5] The smallest element of averages, 5.5, is returned. **Example 2:** **Input:** nums = [1,9,8,3,10,5] **Output:** 5.5 **Explanation:** step nums averages 0 [1,9,8,3,10,5] [] 1 [9,8,3,5] [5.5] 2 [8,5] [5.5,6] 3 [] [5.5,6,6.5] **Example 3:** **Input:** nums = [1,2,3,7,8,9] **Output:** 5.0 **Explanation:** step nums averages 0 [1,2,3,7,8,9] [] 1 [2,3,7,8] [5] 2 [3,7] [5,5] 3 [] [5,5,5] **Constraints:** `2 <= n == nums.length <= 50` `n` is even. `1 <= nums[i] <= 50`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [7,8,3,4,15,13,4,1]",
12
+ "output": "5.5 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,9,8,3,10,5]",
17
+ "output": "5.5 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [1,2,3,7,8,9]",
22
+ "output": "5.0 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 10,
29
+ 11,
30
+ 15,
31
+ 22,
32
+ 22,
33
+ 24
34
+ ],
35
+ "output": 16.5
36
+ },
37
+ {
38
+ "input": [
39
+ 1,
40
+ 1,
41
+ 4,
42
+ 5,
43
+ 9,
44
+ 11,
45
+ 11,
46
+ 12,
47
+ 12,
48
+ 13,
49
+ 14,
50
+ 15,
51
+ 18,
52
+ 20,
53
+ 20,
54
+ 21,
55
+ 21,
56
+ 25,
57
+ 31,
58
+ 33,
59
+ 36,
60
+ 37,
61
+ 39,
62
+ 40,
63
+ 44,
64
+ 45,
65
+ 46,
66
+ 48,
67
+ 48,
68
+ 49,
69
+ 50,
70
+ 50
71
+ ],
72
+ "output": 21.0
73
+ },
74
+ {
75
+ "input": [
76
+ 2,
77
+ 6,
78
+ 6,
79
+ 9,
80
+ 9,
81
+ 16,
82
+ 18,
83
+ 23,
84
+ 26,
85
+ 28,
86
+ 29,
87
+ 31,
88
+ 31,
89
+ 34,
90
+ 36,
91
+ 37,
92
+ 45,
93
+ 48
94
+ ],
95
+ "output": 21.5
96
+ },
97
+ {
98
+ "input": [
99
+ 1,
100
+ 5,
101
+ 6,
102
+ 7,
103
+ 8,
104
+ 9,
105
+ 10,
106
+ 10,
107
+ 11,
108
+ 15,
109
+ 19,
110
+ 20,
111
+ 20,
112
+ 21,
113
+ 29,
114
+ 30,
115
+ 31,
116
+ 32,
117
+ 33,
118
+ 36,
119
+ 37,
120
+ 39,
121
+ 40,
122
+ 41,
123
+ 46,
124
+ 48
125
+ ],
126
+ "output": 20.5
127
+ },
128
+ {
129
+ "input": [
130
+ 5,
131
+ 5,
132
+ 37,
133
+ 43,
134
+ 43,
135
+ 50
136
+ ],
137
+ "output": 24.0
138
+ },
139
+ {
140
+ "input": [
141
+ 1,
142
+ 2,
143
+ 3,
144
+ 3,
145
+ 3,
146
+ 3,
147
+ 4,
148
+ 6,
149
+ 6,
150
+ 7,
151
+ 7,
152
+ 7,
153
+ 8,
154
+ 11,
155
+ 15,
156
+ 16,
157
+ 20,
158
+ 20,
159
+ 21,
160
+ 22,
161
+ 22,
162
+ 26,
163
+ 30,
164
+ 31,
165
+ 31,
166
+ 36,
167
+ 36,
168
+ 37,
169
+ 37,
170
+ 38,
171
+ 38,
172
+ 39,
173
+ 40,
174
+ 42,
175
+ 42,
176
+ 42,
177
+ 49,
178
+ 49,
179
+ 50,
180
+ 50
181
+ ],
182
+ "output": 22.0
183
+ },
184
+ {
185
+ "input": [
186
+ 1,
187
+ 3,
188
+ 4,
189
+ 4,
190
+ 6,
191
+ 7,
192
+ 8,
193
+ 8,
194
+ 9,
195
+ 9,
196
+ 10,
197
+ 11,
198
+ 11,
199
+ 14,
200
+ 15,
201
+ 16,
202
+ 19,
203
+ 20,
204
+ 21,
205
+ 22,
206
+ 22,
207
+ 23,
208
+ 23,
209
+ 24,
210
+ 24,
211
+ 24,
212
+ 26,
213
+ 27,
214
+ 30,
215
+ 32,
216
+ 33,
217
+ 34,
218
+ 35,
219
+ 36,
220
+ 37,
221
+ 37,
222
+ 38,
223
+ 39,
224
+ 40,
225
+ 41,
226
+ 41,
227
+ 43,
228
+ 44,
229
+ 45,
230
+ 46,
231
+ 48,
232
+ 48,
233
+ 49
234
+ ],
235
+ "output": 23.5
236
+ },
237
+ {
238
+ "input": [
239
+ 1,
240
+ 1,
241
+ 1,
242
+ 2,
243
+ 4,
244
+ 4,
245
+ 6,
246
+ 10,
247
+ 10,
248
+ 12,
249
+ 13,
250
+ 15,
251
+ 16,
252
+ 16,
253
+ 16,
254
+ 17,
255
+ 17,
256
+ 17,
257
+ 18,
258
+ 19,
259
+ 21,
260
+ 23,
261
+ 24,
262
+ 28,
263
+ 28,
264
+ 29,
265
+ 33,
266
+ 36,
267
+ 36,
268
+ 36,
269
+ 36,
270
+ 37,
271
+ 37,
272
+ 38,
273
+ 39,
274
+ 39,
275
+ 40,
276
+ 46,
277
+ 48,
278
+ 49,
279
+ 50,
280
+ 50
281
+ ],
282
+ "output": 21.5
283
+ },
284
+ {
285
+ "input": [
286
+ 4,
287
+ 8,
288
+ 11,
289
+ 15,
290
+ 19,
291
+ 23,
292
+ 31,
293
+ 36,
294
+ 39,
295
+ 41,
296
+ 41,
297
+ 49
298
+ ],
299
+ "output": 24.5
300
+ },
301
+ {
302
+ "input": [
303
+ 1,
304
+ 3,
305
+ 6,
306
+ 6,
307
+ 6,
308
+ 6,
309
+ 9,
310
+ 10,
311
+ 13,
312
+ 16,
313
+ 19,
314
+ 20,
315
+ 24,
316
+ 25,
317
+ 27,
318
+ 27,
319
+ 34,
320
+ 34,
321
+ 36,
322
+ 36,
323
+ 37,
324
+ 38,
325
+ 38,
326
+ 39,
327
+ 39,
328
+ 39,
329
+ 39,
330
+ 41,
331
+ 41,
332
+ 41,
333
+ 42,
334
+ 42,
335
+ 42,
336
+ 45,
337
+ 45,
338
+ 46,
339
+ 47,
340
+ 48,
341
+ 49,
342
+ 49,
343
+ 50,
344
+ 50
345
+ ],
346
+ "output": 25.5
347
+ }
348
+ ],
349
+ "haskell_template": "minimumAverage :: [Int] -> Float\nminimumAverage nums ",
350
+ "ocaml_template": "let minimumAverage (nums: int list) : float = ",
351
+ "scala_template": "def minimumAverage(nums: List[Int]): Float = { \n \n}",
352
+ "java_template": "class Solution {\n public double minimumAverage(int[] nums) {\n \n }\n}",
353
+ "python_template": "class Solution(object):\n def minimumAverage(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: float\n \"\"\"\n "
354
+ }
minimum_average_of_smallest_and_largest_elements/ocaml_tests/main.ml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimumAverage (nums: int list) : float = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 5.5 (minimumAverage [7;8;3;4;15;13;4;1])
13
+
14
+ let test2 _ = assert_equal 5.5 (minimumAverage [1;9;8;3;10;5])
15
+
16
+ let test3 _ = assert_equal 5.0 (minimumAverage [1;2;3;7;8;9])
17
+
18
+ let test4 _ = assert_equal 5.0 (minimumAverage [10; 11; 15; 22; 22; 24])
19
+
20
+ let test5 _ = assert_equal 5.0 (minimumAverage [1; 1; 4; 5; 9; 11; 11; 12; 12; 13; 14; 15; 18; 20; 20; 21; 21; 25; 31; 33; 36; 37; 39; 40; 44; 45; 46; 48; 48; 49; 50; 50])
21
+
22
+ let test6 _ = assert_equal 5.0 (minimumAverage [2; 6; 6; 9; 9; 16; 18; 23; 26; 28; 29; 31; 31; 34; 36; 37; 45; 48])
23
+
24
+ let test7 _ = assert_equal 5.0 (minimumAverage [1; 5; 6; 7; 8; 9; 10; 10; 11; 15; 19; 20; 20; 21; 29; 30; 31; 32; 33; 36; 37; 39; 40; 41; 46; 48])
25
+
26
+ let test8 _ = assert_equal 5.0 (minimumAverage [5; 5; 37; 43; 43; 50])
27
+
28
+ let test9 _ = assert_equal 5.0 (minimumAverage [1; 2; 3; 3; 3; 3; 4; 6; 6; 7; 7; 7; 8; 11; 15; 16; 20; 20; 21; 22; 22; 26; 30; 31; 31; 36; 36; 37; 37; 38; 38; 39; 40; 42; 42; 42; 49; 49; 50; 50])
29
+
30
+ let test10 _ = assert_equal 5.0 (minimumAverage [1; 3; 4; 4; 6; 7; 8; 8; 9; 9; 10; 11; 11; 14; 15; 16; 19; 20; 21; 22; 22; 23; 23; 24; 24; 24; 26; 27; 30; 32; 33; 34; 35; 36; 37; 37; 38; 39; 40; 41; 41; 43; 44; 45; 46; 48; 48; 49])
31
+
32
+
33
+ (* Grouping test cases *)
34
+ let suite = "Test Suite for minimumAverage" >::: [
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_average_of_smallest_and_largest_elements/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumAverage(List(7,8,3,4,15,13,4,1)), 5.5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumAverage(List(1,9,8,3,10,5)), 5.5)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumAverage(List(1,2,3,7,8,9)), 5.0)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumAverage(10,11,15,22,22,24), 16.5)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumAverage(1,1,4,5,9,11,11,12,12,13,14,15,18,20,20,21,21,25,31,33,36,37,39,40,44,45,46,48,48,49,50,50), 21.0)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumAverage(2,6,6,9,9,16,18,23,26,28,29,31,31,34,36,37,45,48), 21.5)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumAverage(1,5,6,7,8,9,10,10,11,15,19,20,20,21,29,30,31,32,33,36,37,39,40,41,46,48), 20.5)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumAverage(5,5,37,43,43,50), 24.0)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumAverage(1,2,3,3,3,3,4,6,6,7,7,7,8,11,15,16,20,20,21,22,22,26,30,31,31,36,36,37,37,38,38,39,40,42,42,42,49,49,50,50), 22.0)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumAverage(1,3,4,4,6,7,8,8,9,9,10,11,11,14,15,16,19,20,21,22,22,23,23,24,24,24,26,27,30,32,33,34,35,36,37,37,38,39,40,41,41,43,44,45,46,48,48,49), 23.5)
42
+ }
43
+
44
+ }
minimum_bit_flips_to_convert_number/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_bit_flips_to_convert_number/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 (minBitFlips 10 7)," 3 (minBitFlips 10 7))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minBitFlips 3 4)," 3 (minBitFlips 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
minimum_bit_flips_to_convert_number/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, minBitFlips(10, 7));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, minBitFlips(3, 4));
19
+ }
20
+
21
+ }
minimum_bit_flips_to_convert_number/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2323,
3
+ "name": "minimum_bit_flips_to_convert_number",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-bit-flips-to-convert-number/",
6
+ "date": "1647648000000",
7
+ "task_description": "A **bit flip** of a number `x` is choosing a bit in the binary representation of `x` and **flipping** it from either `0` to `1` or `1` to `0`. For example, for `x = 7`, the binary representation is `111` and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get `110`, flip the second bit from the right to get `101`, flip the fifth bit from the right (a leading zero) to get `10111`, etc. Given two integers `start` and `goal`, return_ the **minimum** number of **bit flips** to convert _`start`_ to _`goal`. **Example 1:** ``` **Input:** start = 10, goal = 7 **Output:** 3 **Explanation:** The binary representation of 10 and 7 are 1010 and 0111 respectively. We can convert 10 to 7 in 3 steps: - Flip the first bit from the right: 1010 -> 1011. - Flip the third bit from the right: 1011 -> 1111. - Flip the fourth bit from the right: 1111 -> 0111. It can be shown we cannot convert 10 to 7 in less than 3 steps. Hence, we return 3. ``` **Example 2:** ``` **Input:** start = 3, goal = 4 **Output:** 3 **Explanation:** The binary representation of 3 and 4 are 011 and 100 respectively. We can convert 3 to 4 in 3 steps: - Flip the first bit from the right: 011 -> 010. - Flip the second bit from the right: 010 -> 000. - Flip the third bit from the right: 000 -> 100. It can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return 3. ``` **Constraints:** `0 <= start, goal <= 109` **Note:** This question is the same as 461: Hamming Distance.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "start = 10, goal = 7",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "start = 3, goal = 4",
17
+ "output": "3 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 464185174,
24
+ 942726219
25
+ ],
26
+ "output": 16
27
+ },
28
+ {
29
+ "input": [
30
+ 592770047,
31
+ 56495577
32
+ ],
33
+ "output": 13
34
+ },
35
+ {
36
+ "input": [
37
+ 485221247,
38
+ 215866542
39
+ ],
40
+ "output": 15
41
+ },
42
+ {
43
+ "input": [
44
+ 269177716,
45
+ 255505893
46
+ ],
47
+ "output": 16
48
+ },
49
+ {
50
+ "input": [
51
+ 196878261,
52
+ 175543110
53
+ ],
54
+ "output": 14
55
+ },
56
+ {
57
+ "input": [
58
+ 531827332,
59
+ 699740652
60
+ ],
61
+ "output": 14
62
+ },
63
+ {
64
+ "input": [
65
+ 137185274,
66
+ 610277760
67
+ ],
68
+ "output": 17
69
+ },
70
+ {
71
+ "input": [
72
+ 667761609,
73
+ 636943338
74
+ ],
75
+ "output": 11
76
+ },
77
+ {
78
+ "input": [
79
+ 853433529,
80
+ 516947521
81
+ ],
82
+ "output": 13
83
+ },
84
+ {
85
+ "input": [
86
+ 208171254,
87
+ 57958222
88
+ ],
89
+ "output": 16
90
+ }
91
+ ],
92
+ "haskell_template": "minBitFlips :: Int -> Int -> Int\nminBitFlips start goal ",
93
+ "ocaml_template": "let minBitFlips (start: int) (goal: int) : int = ",
94
+ "scala_template": "def minBitFlips(start: Int,goal: Int): Int = { \n \n}",
95
+ "java_template": "public static int minBitFlips(int start, int goal) {\n\n}",
96
+ "python_template": "class Solution(object):\n def minBitFlips(self, start, goal):\n \"\"\"\n :type start: int\n :type goal: int\n :rtype: int\n \"\"\"\n "
97
+ }
minimum_bit_flips_to_convert_number/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 (minBitFlips 10 7)
12
+
13
+ let test2 _ = assert_equal 3 (minBitFlips 3 4)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minBitFlips" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimum_bit_flips_to_convert_number/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minBitFlips(10,7), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minBitFlips(3,4), 3)
10
+ }
11
+
12
+ }
minimum_changes_to_make_k_semi_palindromes/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_changes_to_make_k_semi_palindromes/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 (minimumChanges \"abcac \" 2)," 1 (minimumChanges "abcac" 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumChanges \"abcdef \" 2)," 2 (minimumChanges "abcdef" 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumChanges \"aabbaa \" 3)," 0 (minimumChanges "aabbaa" 3))
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_changes_to_make_k_semi_palindromes/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, minimumChanges("abcac", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, minimumChanges("abcdef", 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, minimumChanges("aabbaa", 3));
23
+ }
24
+
25
+ }
minimum_changes_to_make_k_semi_palindromes/meta.json ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2879,
3
+ "name": "minimum_changes_to_make_k_semi_palindromes",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/minimum-changes-to-make-k-semi-palindromes/",
6
+ "date": "1697328000000",
7
+ "task_description": "Given a string `s` and an integer `k`, partition `s` into `k` **substrings** such that the letter changes needed to make each substring a **semi-palindrome** are minimized. Return the _**minimum** number of letter changes_ required_._ A **semi-palindrome** is a special type of string that can be divided into **palindromes** based on a repeating pattern. To check if a string is a semi-palindrome:​ Choose a positive divisor `d` of the string's length. `d` can range from `1` up to, but not including, the string's length. For a string of length `1`, it does not have a valid divisor as per this definition, since the only divisor is its length, which is not allowed. For a given divisor `d`, divide the string into groups where each group contains characters from the string that follow a repeating pattern of length `d`. Specifically, the first group consists of characters at positions `1`, `1 + d`, `1 + 2d`, and so on; the second group includes characters at positions `2`, `2 + d`, `2 + 2d`, etc. The string is considered a semi-palindrome if each of these groups forms a palindrome. Consider the string `\"abcabc\"`: The length of `\"abcabc\"` is `6`. Valid divisors are `1`, `2`, and `3`. For `d = 1`: The entire string `\"abcabc\"` forms one group. Not a palindrome. For `d = 2`: Group 1 (positions `1, 3, 5`): `\"acb\"` Group 2 (positions `2, 4, 6`): `\"bac\"` Neither group forms a palindrome. For `d = 3`: Group 1 (positions `1, 4`): `\"aa\"` Group 2 (positions `2, 5`): `\"bb\"` Group 3 (positions `3, 6`): `\"cc\"` All groups form palindromes. Therefore, `\"abcabc\"` is a semi-palindrome. **Example 1: ** **Input: ** s = \"abcac\", k = 2 **Output: ** 1 **Explanation: ** Divide `s` into `\"ab\"` and `\"cac\"`. `\"cac\"` is already semi-palindrome. Change `\"ab\"` to `\"aa\"`, it becomes semi-palindrome with `d = 1`. **Example 2: ** **Input: ** s = \"abcdef\", k = 2 **Output: ** 2 **Explanation: ** Divide `s` into substrings `\"abc\"` and `\"def\"`. Each needs one change to become semi-palindrome. **Example 3: ** **Input: ** s = \"aabbaa\", k = 3 **Output: ** 0 **Explanation: ** Divide `s` into substrings `\"aa\"`, `\"bb\"` and `\"aa\"`. All are already semi-palindromes. **Constraints:** `2 <= s.length <= 200` `1 <= k <= s.length / 2` `s` contains only lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"abcac\", k = 2",
12
+ "output": "1 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"abcdef\", k = 2",
17
+ "output": "2 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "s = \"aabbaa\", k = 3",
22
+ "output": "0 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ "\"qeklbsbwmpspzubgxvhjtwvdifezgmsqmuylthiwycqbjtcnyfysex\"",
29
+ 25
30
+ ],
31
+ "output": 22
32
+ },
33
+ {
34
+ "input": [
35
+ "\"wucejegrzlclvdsrzcyqgtliyfiznirgdgjrcasacbaieyqebiqrnixcwupbpcamzndrfuupztxeizsyhgnnwaewqgkpautkqiwsbiimwuapnmsruevczmilagmeurgfzqvmsugcjkrteapjdxqqodxavhmblucxrrltiggxgnvchfprwwpwboddyk\"",
36
+ 85
37
+ ],
38
+ "output": 72
39
+ },
40
+ {
41
+ "input": [
42
+ "\"aakcdvvaaucqbedrucmlqoounueroqgjhtkhnisniskzmqfkddfuvwuqxcirnlnjjmrzsgbbfvmwldalpdjfybwkkyyjiyri\"",
43
+ 17
44
+ ],
45
+ "output": 21
46
+ },
47
+ {
48
+ "input": [
49
+ "\"khoehgodguhcouyrdetvrcohmykuwlnbagmouoymfqijlxrwlvsimounchgnjrjuraecishgvwrpsqmwdrbkprfkcatzpjtpvmqqmzfbdnudzwi\"",
50
+ 31
51
+ ],
52
+ "output": 29
53
+ },
54
+ {
55
+ "input": [
56
+ "\"ffhnqiimghsyhmrhdrxupmdfwomkvngqdaancyrgmylvyiltlwbeil\"",
57
+ 18
58
+ ],
59
+ "output": 14
60
+ },
61
+ {
62
+ "input": [
63
+ "\"dyfqgxtyotkvlxnmyzavacketnlsglaeqacvzbbq\"",
64
+ 5
65
+ ],
66
+ "output": 10
67
+ },
68
+ {
69
+ "input": [
70
+ "apelnd",
71
+ 3
72
+ ],
73
+ "output": 3
74
+ },
75
+ {
76
+ "input": [
77
+ "psnfxnvbihzcjmqohksburfkmwqugdbyiigxhssvtdghqjizneosexzlpyqcfrqgpmhswymqpmlzaognrrosjmkvzhpynkmnijloyuhjop",
78
+ 51
79
+ ],
80
+ "output": 48
81
+ },
82
+ {
83
+ "input": [
84
+ "flsnhgiyotwxvpktlcarljrtcuwwbrsmmpsmttgvgereblshhfvozhvksxrqhtkvtiuewchsocdxjpfqcdsczbmazkz",
85
+ 9
86
+ ],
87
+ "output": 23
88
+ },
89
+ {
90
+ "input": [
91
+ "fitudzhdjasdtggvklwg",
92
+ 8
93
+ ],
94
+ "output": 7
95
+ }
96
+ ],
97
+ "haskell_template": "minimumChanges :: String -> Int -> Int\nminimumChanges s k ",
98
+ "ocaml_template": "let minimumChanges (s: string) (k: int) : int = ",
99
+ "scala_template": "def minimumChanges(s: String,k: Int): Int = { \n \n}",
100
+ "java_template": "public static int minimumChanges(String s, int k) {\n\n}",
101
+ "python_template": "class Solution(object):\n def minimumChanges(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: int\n \"\"\"\n "
102
+ }
minimum_changes_to_make_k_semi_palindromes/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 (minimumChanges "abcac" 2)
12
+
13
+ let test2 _ = assert_equal 2 (minimumChanges "abcdef" 2)
14
+
15
+ let test3 _ = assert_equal 0 (minimumChanges "aabbaa" 3)
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for minimumChanges" >::: [
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_changes_to_make_k_semi_palindromes/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumChanges("abcac",2), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumChanges("abcdef",2), 2)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumChanges("aabbaa",3), 0)
14
+ }
15
+
16
+ }
minimum_common_value/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 (getCommon [1,2,3] [2,4])," 2 (getCommon [1,2,3] [2,4]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (getCommon [1,2,3,6] [2,3,4,5])," 2 (getCommon [1,2,3,6] [2,3,4,5]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (getCommon [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 86, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] [1, 3, 20, 21, 22, 25, 26, 32, 37, 38, 39, 40, 42, 43, 44, 46, 48, 50, 56, 57, 58, 59, 67, 68, 69, 71, 72, 80, 83, 87, 89, 92, 93, 96])," 1 (getCommon [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 86, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] [1, 3, 20, 21, 22, 25, 26, 32, 37, 38, 39, 40, 42, 43, 44, 46, 48, 50, 56, 57, 58, 59, 67, 68, 69, 71, 72, 80, 83, 87, 89, 92, 93, 96]))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (getCommon [1, 2, 4, 5, 11, 12, 13, 14, 19, 23, 26, 35, 38, 40, 42, 45, 47, 49, 51, 52, 57, 58, 59, 60, 63, 66, 68, 69, 71, 75, 81, 89, 91, 93, 95] [1, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 28, 29, 30, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 74, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100])," 1 (getCommon [1, 2, 4, 5, 11, 12, 13, 14, 19, 23, 26, 35, 38, 40, 42, 45, 47, 49, 51, 52, 57, 58, 59, 60, 63, 66, 68, 69, 71, 75, 81, 89, 91, 93, 95] [1, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 28, 29, 30, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 74, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100]))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (getCommon [1, 3, 8, 10, 14, 16, 19, 27, 28, 32, 34, 35, 37, 42, 44, 47, 55, 57, 61, 65, 67, 69, 70, 73, 76, 80, 84, 85, 89, 90, 91, 95, 98, 100] [56, 76, 82, 88, 89, 90])," 76 (getCommon [1, 3, 8, 10, 14, 16, 19, 27, 28, 32, 34, 35, 37, 42, 44, 47, 55, 57, 61, 65, 67, 69, 70, 73, 76, 80, 84, 85, 89, 90, 91, 95, 98, 100] [56, 76, 82, 88, 89, 90]))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (getCommon [11, 13, 15, 18, 19, 25, 33, 43, 44, 45, 49, 52, 55, 71, 72, 76, 84, 89, 90, 91, 97] [1, 6, 8, 9, 13, 14, 15, 25, 28, 29, 35, 36, 43, 45, 47, 49, 53, 54, 61, 68, 72, 74, 82, 84, 86, 90, 92, 93, 94, 96, 98])," 13 (getCommon [11, 13, 15, 18, 19, 25, 33, 43, 44, 45, 49, 52, 55, 71, 72, 76, 84, 89, 90, 91, 97] [1, 6, 8, 9, 13, 14, 15, 25, 28, 29, 35, 36, 43, 45, 47, 49, 53, 54, 61, 68, 72, 74, 82, 84, 86, 90, 92, 93, 94, 96, 98]))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (getCommon [3, 5, 6, 13, 14, 16, 17, 20, 21, 22, 24, 26, 27, 28, 29, 34, 37, 38, 39, 41, 42, 43, 45, 47, 48, 50, 51, 52, 53, 57, 58, 59, 60, 62, 64, 65, 67, 68, 72, 74, 76, 77, 78, 79, 80, 82, 83, 84, 86, 87, 89, 91, 93, 94, 95, 96, 98, 99] [2, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 24, 25, 26, 27, 30, 32, 33, 35, 36, 38, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 64, 67, 68, 70, 71, 76, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 96, 98, 99, 100])," 5 (getCommon [3, 5, 6, 13, 14, 16, 17, 20, 21, 22, 24, 26, 27, 28, 29, 34, 37, 38, 39, 41, 42, 43, 45, 47, 48, 50, 51, 52, 53, 57, 58, 59, 60, 62, 64, 65, 67, 68, 72, 74, 76, 77, 78, 79, 80, 82, 83, 84, 86, 87, 89, 91, 93, 94, 95, 96, 98, 99] [2, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 24, 25, 26, 27, 30, 32, 33, 35, 36, 38, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 64, 67, 68, 70, 71, 76, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 96, 98, 99, 100]))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (getCommon [2, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 21, 26, 27, 28, 29, 31, 33, 35, 36, 38, 39, 42, 43, 44, 48, 49, 54, 55, 56, 57, 59, 61, 62, 67, 72, 73, 76, 77, 81, 82, 83, 85, 86, 87, 88, 90, 92, 93, 95, 96, 99] [101, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 126, 127, 128, 129, 131, 132, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 152, 153, 156, 158, 159, 160, 161, 163, 164, 165, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191, 192, 194, 196, 197, 198, 199, 200])," (-1) (getCommon [2, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 21, 26, 27, 28, 29, 31, 33, 35, 36, 38, 39, 42, 43, 44, 48, 49, 54, 55, 56, 57, 59, 61, 62, 67, 72, 73, 76, 77, 81, 82, 83, 85, 86, 87, 88, 90, 92, 93, 95, 96, 99] [101, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 126, 127, 128, 129, 131, 132, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 152, 153, 156, 158, 159, 160, 161, 163, 164, 165, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191, 192, 194, 196, 197, 198, 199, 200]))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (getCommon [4, 31, 55, 59, 80] [102, 104, 105, 106, 107, 108, 109, 110, 111, 114, 115, 116, 117, 118, 121, 123, 124, 126, 127, 128, 129, 133, 134, 135, 137, 140, 141, 142, 145, 146, 147, 150, 151, 153, 155, 157, 160, 163, 167, 168, 172, 173, 175, 176, 177, 178, 179, 188, 189, 190, 196, 198, 200])," (-1) (getCommon [4, 31, 55, 59, 80] [102, 104, 105, 106, 107, 108, 109, 110, 111, 114, 115, 116, 117, 118, 121, 123, 124, 126, 127, 128, 129, 133, 134, 135, 137, 140, 141, 142, 145, 146, 147, 150, 151, 153, 155, 157, 160, 163, 167, 168, 172, 173, 175, 176, 177, 178, 179, 188, 189, 190, 196, 198, 200]))
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_common_value/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, getCommon(new ArrayList<>(Arrays.asList(1,2,3)), new ArrayList<>(Arrays.asList(2,4))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, getCommon(new ArrayList<>(Arrays.asList(1,2,3,6)), new ArrayList<>(Arrays.asList(2,3,4,5))));
19
+ }
20
+
21
+ }
minimum_common_value/meta.json ADDED
@@ -0,0 +1,1153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2634,
3
+ "name": "minimum_common_value",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-common-value/",
6
+ "date": "2023-01-07 00:00:00",
7
+ "task_description": "Given two integer arrays `nums1` and `nums2`, sorted in non-decreasing order, return _the **minimum integer common** to both arrays_. If there is no common integer amongst `nums1` and `nums2`, return `-1`. Note that an integer is said to be **common** to `nums1` and `nums2` if both arrays have **at least one** occurrence of that integer. **Example 1:** ``` **Input:** nums1 = [1,2,3], nums2 = [2,4] **Output:** 2 **Explanation:** The smallest element common to both arrays is 2, so we return 2. ``` **Example 2:** ``` **Input:** nums1 = [1,2,3,6], nums2 = [2,3,4,5] **Output:** 2 **Explanation:** There are two common elements in the array 2 and 3 out of which 2 is the smallest, so 2 is returned. ``` **Constraints:** `1 <= nums1.length, nums2.length <= 105` `1 <= nums1[i], nums2[j] <= 109` Both `nums1` and `nums2` are sorted in **non-decreasing** order.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums1 = [1,2,3], nums2 = [2,4]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums1 = [1,2,3,6], nums2 = [2,3,4,5]",
17
+ "output": "2 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 1,
25
+ 2,
26
+ 3,
27
+ 4,
28
+ 5,
29
+ 6,
30
+ 7,
31
+ 8,
32
+ 9,
33
+ 10,
34
+ 11,
35
+ 12,
36
+ 13,
37
+ 15,
38
+ 16,
39
+ 17,
40
+ 18,
41
+ 20,
42
+ 21,
43
+ 22,
44
+ 23,
45
+ 24,
46
+ 25,
47
+ 26,
48
+ 27,
49
+ 28,
50
+ 29,
51
+ 30,
52
+ 31,
53
+ 32,
54
+ 33,
55
+ 34,
56
+ 35,
57
+ 36,
58
+ 37,
59
+ 38,
60
+ 39,
61
+ 40,
62
+ 41,
63
+ 42,
64
+ 43,
65
+ 44,
66
+ 45,
67
+ 46,
68
+ 47,
69
+ 48,
70
+ 49,
71
+ 50,
72
+ 51,
73
+ 52,
74
+ 53,
75
+ 54,
76
+ 55,
77
+ 56,
78
+ 57,
79
+ 58,
80
+ 59,
81
+ 60,
82
+ 61,
83
+ 62,
84
+ 63,
85
+ 64,
86
+ 65,
87
+ 66,
88
+ 67,
89
+ 68,
90
+ 69,
91
+ 70,
92
+ 71,
93
+ 72,
94
+ 73,
95
+ 74,
96
+ 75,
97
+ 76,
98
+ 77,
99
+ 78,
100
+ 79,
101
+ 80,
102
+ 81,
103
+ 83,
104
+ 86,
105
+ 88,
106
+ 89,
107
+ 90,
108
+ 91,
109
+ 92,
110
+ 93,
111
+ 94,
112
+ 95,
113
+ 96,
114
+ 97,
115
+ 98,
116
+ 99,
117
+ 100
118
+ ],
119
+ [
120
+ 1,
121
+ 3,
122
+ 20,
123
+ 21,
124
+ 22,
125
+ 25,
126
+ 26,
127
+ 32,
128
+ 37,
129
+ 38,
130
+ 39,
131
+ 40,
132
+ 42,
133
+ 43,
134
+ 44,
135
+ 46,
136
+ 48,
137
+ 50,
138
+ 56,
139
+ 57,
140
+ 58,
141
+ 59,
142
+ 67,
143
+ 68,
144
+ 69,
145
+ 71,
146
+ 72,
147
+ 80,
148
+ 83,
149
+ 87,
150
+ 89,
151
+ 92,
152
+ 93,
153
+ 96
154
+ ]
155
+ ],
156
+ "output": 1
157
+ },
158
+ {
159
+ "input": [
160
+ [
161
+ 1,
162
+ 2,
163
+ 4,
164
+ 5,
165
+ 11,
166
+ 12,
167
+ 13,
168
+ 14,
169
+ 19,
170
+ 23,
171
+ 26,
172
+ 35,
173
+ 38,
174
+ 40,
175
+ 42,
176
+ 45,
177
+ 47,
178
+ 49,
179
+ 51,
180
+ 52,
181
+ 57,
182
+ 58,
183
+ 59,
184
+ 60,
185
+ 63,
186
+ 66,
187
+ 68,
188
+ 69,
189
+ 71,
190
+ 75,
191
+ 81,
192
+ 89,
193
+ 91,
194
+ 93,
195
+ 95
196
+ ],
197
+ [
198
+ 1,
199
+ 3,
200
+ 4,
201
+ 5,
202
+ 7,
203
+ 8,
204
+ 9,
205
+ 10,
206
+ 11,
207
+ 12,
208
+ 13,
209
+ 14,
210
+ 15,
211
+ 16,
212
+ 18,
213
+ 19,
214
+ 20,
215
+ 22,
216
+ 23,
217
+ 24,
218
+ 26,
219
+ 28,
220
+ 29,
221
+ 30,
222
+ 33,
223
+ 34,
224
+ 35,
225
+ 36,
226
+ 37,
227
+ 38,
228
+ 40,
229
+ 41,
230
+ 42,
231
+ 43,
232
+ 44,
233
+ 45,
234
+ 46,
235
+ 47,
236
+ 48,
237
+ 49,
238
+ 51,
239
+ 52,
240
+ 53,
241
+ 55,
242
+ 58,
243
+ 60,
244
+ 61,
245
+ 62,
246
+ 63,
247
+ 64,
248
+ 65,
249
+ 66,
250
+ 67,
251
+ 68,
252
+ 69,
253
+ 70,
254
+ 74,
255
+ 76,
256
+ 79,
257
+ 80,
258
+ 81,
259
+ 82,
260
+ 83,
261
+ 84,
262
+ 85,
263
+ 86,
264
+ 87,
265
+ 88,
266
+ 89,
267
+ 90,
268
+ 91,
269
+ 92,
270
+ 93,
271
+ 94,
272
+ 95,
273
+ 96,
274
+ 97,
275
+ 99,
276
+ 100
277
+ ]
278
+ ],
279
+ "output": 1
280
+ },
281
+ {
282
+ "input": [
283
+ [
284
+ 1,
285
+ 3,
286
+ 8,
287
+ 10,
288
+ 14,
289
+ 16,
290
+ 19,
291
+ 27,
292
+ 28,
293
+ 32,
294
+ 34,
295
+ 35,
296
+ 37,
297
+ 42,
298
+ 44,
299
+ 47,
300
+ 55,
301
+ 57,
302
+ 61,
303
+ 65,
304
+ 67,
305
+ 69,
306
+ 70,
307
+ 73,
308
+ 76,
309
+ 80,
310
+ 84,
311
+ 85,
312
+ 89,
313
+ 90,
314
+ 91,
315
+ 95,
316
+ 98,
317
+ 100
318
+ ],
319
+ [
320
+ 56,
321
+ 76,
322
+ 82,
323
+ 88,
324
+ 89,
325
+ 90
326
+ ]
327
+ ],
328
+ "output": 76
329
+ },
330
+ {
331
+ "input": [
332
+ [
333
+ 11,
334
+ 13,
335
+ 15,
336
+ 18,
337
+ 19,
338
+ 25,
339
+ 33,
340
+ 43,
341
+ 44,
342
+ 45,
343
+ 49,
344
+ 52,
345
+ 55,
346
+ 71,
347
+ 72,
348
+ 76,
349
+ 84,
350
+ 89,
351
+ 90,
352
+ 91,
353
+ 97
354
+ ],
355
+ [
356
+ 1,
357
+ 6,
358
+ 8,
359
+ 9,
360
+ 13,
361
+ 14,
362
+ 15,
363
+ 25,
364
+ 28,
365
+ 29,
366
+ 35,
367
+ 36,
368
+ 43,
369
+ 45,
370
+ 47,
371
+ 49,
372
+ 53,
373
+ 54,
374
+ 61,
375
+ 68,
376
+ 72,
377
+ 74,
378
+ 82,
379
+ 84,
380
+ 86,
381
+ 90,
382
+ 92,
383
+ 93,
384
+ 94,
385
+ 96,
386
+ 98
387
+ ]
388
+ ],
389
+ "output": 13
390
+ },
391
+ {
392
+ "input": [
393
+ [
394
+ 3,
395
+ 5,
396
+ 6,
397
+ 13,
398
+ 14,
399
+ 16,
400
+ 17,
401
+ 20,
402
+ 21,
403
+ 22,
404
+ 24,
405
+ 26,
406
+ 27,
407
+ 28,
408
+ 29,
409
+ 34,
410
+ 37,
411
+ 38,
412
+ 39,
413
+ 41,
414
+ 42,
415
+ 43,
416
+ 45,
417
+ 47,
418
+ 48,
419
+ 50,
420
+ 51,
421
+ 52,
422
+ 53,
423
+ 57,
424
+ 58,
425
+ 59,
426
+ 60,
427
+ 62,
428
+ 64,
429
+ 65,
430
+ 67,
431
+ 68,
432
+ 72,
433
+ 74,
434
+ 76,
435
+ 77,
436
+ 78,
437
+ 79,
438
+ 80,
439
+ 82,
440
+ 83,
441
+ 84,
442
+ 86,
443
+ 87,
444
+ 89,
445
+ 91,
446
+ 93,
447
+ 94,
448
+ 95,
449
+ 96,
450
+ 98,
451
+ 99
452
+ ],
453
+ [
454
+ 2,
455
+ 5,
456
+ 6,
457
+ 8,
458
+ 9,
459
+ 10,
460
+ 11,
461
+ 12,
462
+ 13,
463
+ 14,
464
+ 15,
465
+ 16,
466
+ 18,
467
+ 19,
468
+ 20,
469
+ 22,
470
+ 24,
471
+ 25,
472
+ 26,
473
+ 27,
474
+ 30,
475
+ 32,
476
+ 33,
477
+ 35,
478
+ 36,
479
+ 38,
480
+ 40,
481
+ 41,
482
+ 42,
483
+ 43,
484
+ 44,
485
+ 45,
486
+ 47,
487
+ 48,
488
+ 49,
489
+ 50,
490
+ 51,
491
+ 52,
492
+ 53,
493
+ 54,
494
+ 55,
495
+ 57,
496
+ 58,
497
+ 59,
498
+ 60,
499
+ 64,
500
+ 67,
501
+ 68,
502
+ 70,
503
+ 71,
504
+ 76,
505
+ 78,
506
+ 79,
507
+ 80,
508
+ 81,
509
+ 82,
510
+ 84,
511
+ 85,
512
+ 86,
513
+ 87,
514
+ 88,
515
+ 89,
516
+ 90,
517
+ 92,
518
+ 93,
519
+ 94,
520
+ 96,
521
+ 98,
522
+ 99,
523
+ 100
524
+ ]
525
+ ],
526
+ "output": 5
527
+ },
528
+ {
529
+ "input": [
530
+ [
531
+ 2,
532
+ 5,
533
+ 6,
534
+ 7,
535
+ 9,
536
+ 10,
537
+ 11,
538
+ 13,
539
+ 14,
540
+ 15,
541
+ 17,
542
+ 21,
543
+ 26,
544
+ 27,
545
+ 28,
546
+ 29,
547
+ 31,
548
+ 33,
549
+ 35,
550
+ 36,
551
+ 38,
552
+ 39,
553
+ 42,
554
+ 43,
555
+ 44,
556
+ 48,
557
+ 49,
558
+ 54,
559
+ 55,
560
+ 56,
561
+ 57,
562
+ 59,
563
+ 61,
564
+ 62,
565
+ 67,
566
+ 72,
567
+ 73,
568
+ 76,
569
+ 77,
570
+ 81,
571
+ 82,
572
+ 83,
573
+ 85,
574
+ 86,
575
+ 87,
576
+ 88,
577
+ 90,
578
+ 92,
579
+ 93,
580
+ 95,
581
+ 96,
582
+ 99
583
+ ],
584
+ [
585
+ 101,
586
+ 103,
587
+ 104,
588
+ 105,
589
+ 106,
590
+ 107,
591
+ 108,
592
+ 109,
593
+ 110,
594
+ 111,
595
+ 113,
596
+ 114,
597
+ 115,
598
+ 116,
599
+ 117,
600
+ 118,
601
+ 119,
602
+ 120,
603
+ 121,
604
+ 122,
605
+ 123,
606
+ 126,
607
+ 127,
608
+ 128,
609
+ 129,
610
+ 131,
611
+ 132,
612
+ 134,
613
+ 135,
614
+ 136,
615
+ 137,
616
+ 138,
617
+ 140,
618
+ 141,
619
+ 142,
620
+ 143,
621
+ 144,
622
+ 145,
623
+ 146,
624
+ 147,
625
+ 148,
626
+ 150,
627
+ 152,
628
+ 153,
629
+ 156,
630
+ 158,
631
+ 159,
632
+ 160,
633
+ 161,
634
+ 163,
635
+ 164,
636
+ 165,
637
+ 167,
638
+ 168,
639
+ 170,
640
+ 171,
641
+ 172,
642
+ 173,
643
+ 174,
644
+ 175,
645
+ 176,
646
+ 177,
647
+ 178,
648
+ 179,
649
+ 180,
650
+ 181,
651
+ 182,
652
+ 183,
653
+ 184,
654
+ 185,
655
+ 186,
656
+ 187,
657
+ 188,
658
+ 190,
659
+ 191,
660
+ 192,
661
+ 194,
662
+ 196,
663
+ 197,
664
+ 198,
665
+ 199,
666
+ 200
667
+ ]
668
+ ],
669
+ "output": -1
670
+ },
671
+ {
672
+ "input": [
673
+ [
674
+ 4,
675
+ 31,
676
+ 55,
677
+ 59,
678
+ 80
679
+ ],
680
+ [
681
+ 102,
682
+ 104,
683
+ 105,
684
+ 106,
685
+ 107,
686
+ 108,
687
+ 109,
688
+ 110,
689
+ 111,
690
+ 114,
691
+ 115,
692
+ 116,
693
+ 117,
694
+ 118,
695
+ 121,
696
+ 123,
697
+ 124,
698
+ 126,
699
+ 127,
700
+ 128,
701
+ 129,
702
+ 133,
703
+ 134,
704
+ 135,
705
+ 137,
706
+ 140,
707
+ 141,
708
+ 142,
709
+ 145,
710
+ 146,
711
+ 147,
712
+ 150,
713
+ 151,
714
+ 153,
715
+ 155,
716
+ 157,
717
+ 160,
718
+ 163,
719
+ 167,
720
+ 168,
721
+ 172,
722
+ 173,
723
+ 175,
724
+ 176,
725
+ 177,
726
+ 178,
727
+ 179,
728
+ 188,
729
+ 189,
730
+ 190,
731
+ 196,
732
+ 198,
733
+ 200
734
+ ]
735
+ ],
736
+ "output": -1
737
+ },
738
+ {
739
+ "input": [
740
+ [
741
+ 1,
742
+ 2,
743
+ 3,
744
+ 4,
745
+ 5,
746
+ 6,
747
+ 8,
748
+ 9,
749
+ 10,
750
+ 12,
751
+ 13,
752
+ 14,
753
+ 15,
754
+ 16,
755
+ 17,
756
+ 18,
757
+ 19,
758
+ 20,
759
+ 21,
760
+ 22,
761
+ 23,
762
+ 24,
763
+ 25,
764
+ 26,
765
+ 27,
766
+ 28,
767
+ 30,
768
+ 31,
769
+ 32,
770
+ 33,
771
+ 34,
772
+ 35,
773
+ 36,
774
+ 37,
775
+ 38,
776
+ 39,
777
+ 40,
778
+ 41,
779
+ 42,
780
+ 43,
781
+ 44,
782
+ 45,
783
+ 46,
784
+ 47,
785
+ 48,
786
+ 49,
787
+ 50,
788
+ 51,
789
+ 52,
790
+ 53,
791
+ 54,
792
+ 55,
793
+ 57,
794
+ 58,
795
+ 59,
796
+ 60,
797
+ 61,
798
+ 62,
799
+ 63,
800
+ 64,
801
+ 65,
802
+ 66,
803
+ 67,
804
+ 68,
805
+ 69,
806
+ 70,
807
+ 71,
808
+ 72,
809
+ 73,
810
+ 74,
811
+ 75,
812
+ 76,
813
+ 77,
814
+ 78,
815
+ 79,
816
+ 81,
817
+ 82,
818
+ 83,
819
+ 84,
820
+ 85,
821
+ 86,
822
+ 87,
823
+ 88,
824
+ 89,
825
+ 90,
826
+ 92,
827
+ 93,
828
+ 94,
829
+ 95,
830
+ 96,
831
+ 97,
832
+ 98,
833
+ 99
834
+ ],
835
+ [
836
+ 101,
837
+ 102,
838
+ 103,
839
+ 104,
840
+ 105,
841
+ 107,
842
+ 108,
843
+ 109,
844
+ 110,
845
+ 112,
846
+ 113,
847
+ 115,
848
+ 116,
849
+ 117,
850
+ 118,
851
+ 119,
852
+ 120,
853
+ 121,
854
+ 123,
855
+ 124,
856
+ 125,
857
+ 126,
858
+ 128,
859
+ 129,
860
+ 131,
861
+ 132,
862
+ 133,
863
+ 134,
864
+ 135,
865
+ 136,
866
+ 137,
867
+ 138,
868
+ 140,
869
+ 141,
870
+ 142,
871
+ 143,
872
+ 144,
873
+ 145,
874
+ 147,
875
+ 148,
876
+ 149,
877
+ 150,
878
+ 151,
879
+ 153,
880
+ 154,
881
+ 155,
882
+ 156,
883
+ 157,
884
+ 158,
885
+ 159,
886
+ 160,
887
+ 161,
888
+ 162,
889
+ 163,
890
+ 166,
891
+ 167,
892
+ 168,
893
+ 169,
894
+ 170,
895
+ 172,
896
+ 173,
897
+ 174,
898
+ 175,
899
+ 176,
900
+ 177,
901
+ 178,
902
+ 179,
903
+ 181,
904
+ 182,
905
+ 183,
906
+ 185,
907
+ 186,
908
+ 187,
909
+ 188,
910
+ 189,
911
+ 190,
912
+ 191,
913
+ 192,
914
+ 193,
915
+ 194,
916
+ 195,
917
+ 196,
918
+ 197,
919
+ 198,
920
+ 199,
921
+ 200
922
+ ]
923
+ ],
924
+ "output": -1
925
+ },
926
+ {
927
+ "input": [
928
+ [
929
+ 1,
930
+ 2,
931
+ 3,
932
+ 4,
933
+ 5,
934
+ 6,
935
+ 7,
936
+ 8,
937
+ 9,
938
+ 10,
939
+ 11,
940
+ 12,
941
+ 15,
942
+ 16,
943
+ 17,
944
+ 18,
945
+ 19,
946
+ 20,
947
+ 21,
948
+ 22,
949
+ 23,
950
+ 24,
951
+ 25,
952
+ 26,
953
+ 27,
954
+ 28,
955
+ 29,
956
+ 30,
957
+ 31,
958
+ 32,
959
+ 33,
960
+ 34,
961
+ 35,
962
+ 36,
963
+ 37,
964
+ 38,
965
+ 39,
966
+ 40,
967
+ 41,
968
+ 42,
969
+ 43,
970
+ 44,
971
+ 45,
972
+ 46,
973
+ 47,
974
+ 48,
975
+ 50,
976
+ 51,
977
+ 52,
978
+ 53,
979
+ 54,
980
+ 55,
981
+ 56,
982
+ 57,
983
+ 58,
984
+ 59,
985
+ 60,
986
+ 61,
987
+ 62,
988
+ 64,
989
+ 66,
990
+ 67,
991
+ 68,
992
+ 69,
993
+ 70,
994
+ 72,
995
+ 73,
996
+ 74,
997
+ 75,
998
+ 76,
999
+ 77,
1000
+ 78,
1001
+ 79,
1002
+ 80,
1003
+ 81,
1004
+ 82,
1005
+ 83,
1006
+ 84,
1007
+ 86,
1008
+ 87,
1009
+ 88,
1010
+ 89,
1011
+ 90,
1012
+ 91,
1013
+ 92,
1014
+ 93,
1015
+ 94,
1016
+ 95,
1017
+ 96,
1018
+ 97,
1019
+ 98,
1020
+ 99,
1021
+ 100
1022
+ ],
1023
+ [
1024
+ 101,
1025
+ 103,
1026
+ 104,
1027
+ 105,
1028
+ 106,
1029
+ 108,
1030
+ 109,
1031
+ 110,
1032
+ 112,
1033
+ 114,
1034
+ 115,
1035
+ 117,
1036
+ 118,
1037
+ 119,
1038
+ 120,
1039
+ 122,
1040
+ 124,
1041
+ 125,
1042
+ 126,
1043
+ 127,
1044
+ 129,
1045
+ 131,
1046
+ 133,
1047
+ 134,
1048
+ 135,
1049
+ 138,
1050
+ 140,
1051
+ 141,
1052
+ 144,
1053
+ 145,
1054
+ 146,
1055
+ 147,
1056
+ 152,
1057
+ 153,
1058
+ 154,
1059
+ 157,
1060
+ 158,
1061
+ 159,
1062
+ 160,
1063
+ 162,
1064
+ 163,
1065
+ 164,
1066
+ 165,
1067
+ 167,
1068
+ 168,
1069
+ 170,
1070
+ 172,
1071
+ 177,
1072
+ 179,
1073
+ 181,
1074
+ 183,
1075
+ 187,
1076
+ 188,
1077
+ 189,
1078
+ 190,
1079
+ 191,
1080
+ 192,
1081
+ 194,
1082
+ 200
1083
+ ]
1084
+ ],
1085
+ "output": -1
1086
+ },
1087
+ {
1088
+ "input": [
1089
+ [
1090
+ 5,
1091
+ 8,
1092
+ 9,
1093
+ 12,
1094
+ 13,
1095
+ 15,
1096
+ 21,
1097
+ 23,
1098
+ 24,
1099
+ 25,
1100
+ 28,
1101
+ 30,
1102
+ 31,
1103
+ 32,
1104
+ 33,
1105
+ 36,
1106
+ 44,
1107
+ 45,
1108
+ 49,
1109
+ 52,
1110
+ 56,
1111
+ 58,
1112
+ 61,
1113
+ 68,
1114
+ 72,
1115
+ 75,
1116
+ 76,
1117
+ 79,
1118
+ 80,
1119
+ 84,
1120
+ 87,
1121
+ 88,
1122
+ 90,
1123
+ 91,
1124
+ 92,
1125
+ 94,
1126
+ 97
1127
+ ],
1128
+ [
1129
+ 103,
1130
+ 108,
1131
+ 113,
1132
+ 116,
1133
+ 141,
1134
+ 146,
1135
+ 151,
1136
+ 162,
1137
+ 168,
1138
+ 171,
1139
+ 173,
1140
+ 176,
1141
+ 182,
1142
+ 199
1143
+ ]
1144
+ ],
1145
+ "output": -1
1146
+ }
1147
+ ],
1148
+ "haskell_template": "getCommon :: [Int] -> [Int] -> Int\ngetCommon nums1 nums2 ",
1149
+ "ocaml_template": "let getCommon (nums1: int list) (nums2: int list) : int = ",
1150
+ "scala_template": "def getCommon(nums1: List[Int],nums2: List[Int]): Int = { \n \n}",
1151
+ "java_template": "class Solution {\n public int getCommon(int[] nums1, int[] nums2) {\n \n }\n}",
1152
+ "python_template": "class Solution(object):\n def getCommon(self, nums1, nums2):\n \"\"\"\n :type nums1: List[int]\n :type nums2: List[int]\n :rtype: int\n \"\"\"\n "
1153
+ }
minimum_common_value/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 2 (getCommon [1;2;3] [2;4])
12
+
13
+ let test2 _ = assert_equal 2 (getCommon [1;2;3;6] [2;3;4;5])
14
+
15
+ let test3 _ = assert_equal 1 (getCommon [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 15; 16; 17; 18; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78; 79; 80; 81; 83; 86; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 98; 99; 100] [1; 3; 20; 21; 22; 25; 26; 32; 37; 38; 39; 40; 42; 43; 44; 46; 48; 50; 56; 57; 58; 59; 67; 68; 69; 71; 72; 80; 83; 87; 89; 92; 93; 96])
16
+
17
+ let test4 _ = assert_equal 1 (getCommon [1; 2; 4; 5; 11; 12; 13; 14; 19; 23; 26; 35; 38; 40; 42; 45; 47; 49; 51; 52; 57; 58; 59; 60; 63; 66; 68; 69; 71; 75; 81; 89; 91; 93; 95] [1; 3; 4; 5; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 18; 19; 20; 22; 23; 24; 26; 28; 29; 30; 33; 34; 35; 36; 37; 38; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 51; 52; 53; 55; 58; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 74; 76; 79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97; 99; 100])
18
+
19
+ let test5 _ = assert_equal 76 (getCommon [1; 3; 8; 10; 14; 16; 19; 27; 28; 32; 34; 35; 37; 42; 44; 47; 55; 57; 61; 65; 67; 69; 70; 73; 76; 80; 84; 85; 89; 90; 91; 95; 98; 100] [56; 76; 82; 88; 89; 90])
20
+
21
+ let test6 _ = assert_equal 13 (getCommon [11; 13; 15; 18; 19; 25; 33; 43; 44; 45; 49; 52; 55; 71; 72; 76; 84; 89; 90; 91; 97] [1; 6; 8; 9; 13; 14; 15; 25; 28; 29; 35; 36; 43; 45; 47; 49; 53; 54; 61; 68; 72; 74; 82; 84; 86; 90; 92; 93; 94; 96; 98])
22
+
23
+ let test7 _ = assert_equal 5 (getCommon [3; 5; 6; 13; 14; 16; 17; 20; 21; 22; 24; 26; 27; 28; 29; 34; 37; 38; 39; 41; 42; 43; 45; 47; 48; 50; 51; 52; 53; 57; 58; 59; 60; 62; 64; 65; 67; 68; 72; 74; 76; 77; 78; 79; 80; 82; 83; 84; 86; 87; 89; 91; 93; 94; 95; 96; 98; 99] [2; 5; 6; 8; 9; 10; 11; 12; 13; 14; 15; 16; 18; 19; 20; 22; 24; 25; 26; 27; 30; 32; 33; 35; 36; 38; 40; 41; 42; 43; 44; 45; 47; 48; 49; 50; 51; 52; 53; 54; 55; 57; 58; 59; 60; 64; 67; 68; 70; 71; 76; 78; 79; 80; 81; 82; 84; 85; 86; 87; 88; 89; 90; 92; 93; 94; 96; 98; 99; 100])
24
+
25
+ let test8 _ = assert_equal (-1) (getCommon [2; 5; 6; 7; 9; 10; 11; 13; 14; 15; 17; 21; 26; 27; 28; 29; 31; 33; 35; 36; 38; 39; 42; 43; 44; 48; 49; 54; 55; 56; 57; 59; 61; 62; 67; 72; 73; 76; 77; 81; 82; 83; 85; 86; 87; 88; 90; 92; 93; 95; 96; 99] [101; 103; 104; 105; 106; 107; 108; 109; 110; 111; 113; 114; 115; 116; 117; 118; 119; 120; 121; 122; 123; 126; 127; 128; 129; 131; 132; 134; 135; 136; 137; 138; 140; 141; 142; 143; 144; 145; 146; 147; 148; 150; 152; 153; 156; 158; 159; 160; 161; 163; 164; 165; 167; 168; 170; 171; 172; 173; 174; 175; 176; 177; 178; 179; 180; 181; 182; 183; 184; 185; 186; 187; 188; 190; 191; 192; 194; 196; 197; 198; 199; 200])
26
+
27
+ let test9 _ = assert_equal (-1) (getCommon [4; 31; 55; 59; 80] [102; 104; 105; 106; 107; 108; 109; 110; 111; 114; 115; 116; 117; 118; 121; 123; 124; 126; 127; 128; 129; 133; 134; 135; 137; 140; 141; 142; 145; 146; 147; 150; 151; 153; 155; 157; 160; 163; 167; 168; 172; 173; 175; 176; 177; 178; 179; 188; 189; 190; 196; 198; 200])
28
+
29
+ let test10 _ = assert_equal (-1) (getCommon [1; 2; 3; 4; 5; 6; 8; 9; 10; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 57; 58; 59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78; 79; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 92; 93; 94; 95; 96; 97; 98; 99] [101; 102; 103; 104; 105; 107; 108; 109; 110; 112; 113; 115; 116; 117; 118; 119; 120; 121; 123; 124; 125; 126; 128; 129; 131; 132; 133; 134; 135; 136; 137; 138; 140; 141; 142; 143; 144; 145; 147; 148; 149; 150; 151; 153; 154; 155; 156; 157; 158; 159; 160; 161; 162; 163; 166; 167; 168; 169; 170; 172; 173; 174; 175; 176; 177; 178; 179; 181; 182; 183; 185; 186; 187; 188; 189; 190; 191; 192; 193; 194; 195; 196; 197; 198; 199; 200])
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for getCommon" >::: [
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_common_value/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.getCommon(List(1,2,3),List(2,4)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.getCommon(List(1,2,3,6),List(2,3,4,5)), 2)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.getCommon(List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83, 86, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100),List(1, 3, 20, 21, 22, 25, 26, 32, 37, 38, 39, 40, 42, 43, 44, 46, 48, 50, 56, 57, 58, 59, 67, 68, 69, 71, 72, 80, 83, 87, 89, 92, 93, 96)), 1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.getCommon(List(1, 2, 4, 5, 11, 12, 13, 14, 19, 23, 26, 35, 38, 40, 42, 45, 47, 49, 51, 52, 57, 58, 59, 60, 63, 66, 68, 69, 71, 75, 81, 89, 91, 93, 95),List(1, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 28, 29, 30, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 74, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100)), 1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.getCommon(List(1, 3, 8, 10, 14, 16, 19, 27, 28, 32, 34, 35, 37, 42, 44, 47, 55, 57, 61, 65, 67, 69, 70, 73, 76, 80, 84, 85, 89, 90, 91, 95, 98, 100),List(56, 76, 82, 88, 89, 90)), 76)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.getCommon(List(11, 13, 15, 18, 19, 25, 33, 43, 44, 45, 49, 52, 55, 71, 72, 76, 84, 89, 90, 91, 97),List(1, 6, 8, 9, 13, 14, 15, 25, 28, 29, 35, 36, 43, 45, 47, 49, 53, 54, 61, 68, 72, 74, 82, 84, 86, 90, 92, 93, 94, 96, 98)), 13)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.getCommon(List(3, 5, 6, 13, 14, 16, 17, 20, 21, 22, 24, 26, 27, 28, 29, 34, 37, 38, 39, 41, 42, 43, 45, 47, 48, 50, 51, 52, 53, 57, 58, 59, 60, 62, 64, 65, 67, 68, 72, 74, 76, 77, 78, 79, 80, 82, 83, 84, 86, 87, 89, 91, 93, 94, 95, 96, 98, 99),List(2, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 22, 24, 25, 26, 27, 30, 32, 33, 35, 36, 38, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 64, 67, 68, 70, 71, 76, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 96, 98, 99, 100)), 5)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.getCommon(List(2, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 21, 26, 27, 28, 29, 31, 33, 35, 36, 38, 39, 42, 43, 44, 48, 49, 54, 55, 56, 57, 59, 61, 62, 67, 72, 73, 76, 77, 81, 82, 83, 85, 86, 87, 88, 90, 92, 93, 95, 96, 99),List(101, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 126, 127, 128, 129, 131, 132, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 152, 153, 156, 158, 159, 160, 161, 163, 164, 165, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191, 192, 194, 196, 197, 198, 199, 200)), -1)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.getCommon(List(4, 31, 55, 59, 80),List(102, 104, 105, 106, 107, 108, 109, 110, 111, 114, 115, 116, 117, 118, 121, 123, 124, 126, 127, 128, 129, 133, 134, 135, 137, 140, 141, 142, 145, 146, 147, 150, 151, 153, 155, 157, 160, 163, 167, 168, 172, 173, 175, 176, 177, 178, 179, 188, 189, 190, 196, 198, 200)), -1)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.getCommon(List(1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92, 93, 94, 95, 96, 97, 98, 99),List(101, 102, 103, 104, 105, 107, 108, 109, 110, 112, 113, 115, 116, 117, 118, 119, 120, 121, 123, 124, 125, 126, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 166, 167, 168, 169, 170, 172, 173, 174, 175, 176, 177, 178, 179, 181, 182, 183, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200)), -1)
42
+ }
43
+
44
+ }
minimum_consecutive_cards_to_pick_up/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_consecutive_cards_to_pick_up/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 (minimumCardPickup [3,4,2,3,4,7])," 4 (minimumCardPickup [3,4,2,3,4,7]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumCardPickup [1,0,5,3])," (-1) (minimumCardPickup [1,0,5,3]))
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_consecutive_cards_to_pick_up/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, minimumCardPickup(new ArrayList<>(Arrays.asList(3,4,2,3,4,7))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, minimumCardPickup(new ArrayList<>(Arrays.asList(1,0,5,3))));
19
+ }
20
+
21
+ }
minimum_consecutive_cards_to_pick_up/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_consecutive_cards_to_pick_up/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 4 (minimumCardPickup [3;4;2;3;4;7])
12
+
13
+ let test2 _ = assert_equal (-1) (minimumCardPickup [1;0;5;3])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimumCardPickup" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimum_consecutive_cards_to_pick_up/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumCardPickup(List(3,4,2,3,4,7)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumCardPickup(List(1,0,5,3)), -1)
10
+ }
11
+
12
+ }
minimum_cost_for_cutting_cake_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 (minimumCost 3 2 [1,3] [5])," 13 (minimumCost 3 2 [1,3] [5]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumCost 2 2 [7] [4])," 15 (minimumCost 2 2 [7] [4]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumCost 9 19 [] [])," 7332 (minimumCost 9 19 [] []))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minimumCost 13 20 [] [])," 9876 (minimumCost 13 20 [] []))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minimumCost 1 14 [] [])," 815 (minimumCost 1 14 [] []))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minimumCost 15 1 [] [])," 826 (minimumCost 15 1 [] []))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minimumCost 13 7 [] [])," 4489 (minimumCost 13 7 [] []))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minimumCost 18 20 [] [])," 9671 (minimumCost 18 20 [] []))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minimumCost 8 17 [] [])," 4105 (minimumCost 8 17 [] []))
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_cost_for_cutting_cake_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(13, minimumCost(3, 2, new ArrayList<>(Arrays.asList(1,3)), new ArrayList<>(Arrays.asList(5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(15, minimumCost(2, 2, new ArrayList<>(Arrays.asList(7)), new ArrayList<>(Arrays.asList(4))));
19
+ }
20
+
21
+ }
minimum_cost_for_cutting_cake_i/meta.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3494,
3
+ "name": "minimum_cost_for_cutting_cake_i",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-i/",
6
+ "date": "2024-07-07 00:00:00",
7
+ "task_description": "There is an `m x n` cake that needs to be cut into `1 x 1` pieces. You are given integers `m`, `n`, and two arrays: `horizontalCut` of size `m - 1`, where `horizontalCut[i]` represents the cost to cut along the horizontal line `i`. `verticalCut` of size `n - 1`, where `verticalCut[j]` represents the cost to cut along the vertical line `j`. In one operation, you can choose any piece of cake that is not yet a `1 x 1` square and perform one of the following cuts: Cut along a horizontal line `i` at a cost of `horizontalCut[i]`. Cut along a vertical line `j` at a cost of `verticalCut[j]`. After the cut, the piece of cake is divided into two distinct pieces. The cost of a cut depends only on the initial cost of the line and does not change. Return the **minimum** total cost to cut the entire cake into `1 x 1` pieces. **Example 1:** **Input:** m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5] **Output:** 13 **Explanation:** Perform a cut on the vertical line 0 with cost 5, current total cost is 5. Perform a cut on the horizontal line 0 on `3 x 1` subgrid with cost 1. Perform a cut on the horizontal line 0 on `3 x 1` subgrid with cost 1. Perform a cut on the horizontal line 1 on `2 x 1` subgrid with cost 3. Perform a cut on the horizontal line 1 on `2 x 1` subgrid with cost 3. The total cost is `5 + 1 + 1 + 3 + 3 = 13`. **Example 2:** **Input:** m = 2, n = 2, horizontalCut = [7], verticalCut = [4] **Output:** 15 **Explanation:** Perform a cut on the horizontal line 0 with cost 7. Perform a cut on the vertical line 0 on `1 x 2` subgrid with cost 4. Perform a cut on the vertical line 0 on `1 x 2` subgrid with cost 4. The total cost is `7 + 4 + 4 = 15`. **Constraints:** `1 <= m, n <= 20` `horizontalCut.length == m - 1` `verticalCut.length == n - 1` `1 <= horizontalCut[i], verticalCut[i] <= 103`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5]",
12
+ "output": "13 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "m = 2, n = 2, horizontalCut = [7], verticalCut = [4]",
17
+ "output": "15 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 9,
24
+ 19,
25
+ [],
26
+ []
27
+ ],
28
+ "output": 7332
29
+ },
30
+ {
31
+ "input": [
32
+ 13,
33
+ 20,
34
+ [],
35
+ []
36
+ ],
37
+ "output": 9876
38
+ },
39
+ {
40
+ "input": [
41
+ 1,
42
+ 14,
43
+ [],
44
+ []
45
+ ],
46
+ "output": 815
47
+ },
48
+ {
49
+ "input": [
50
+ 15,
51
+ 1,
52
+ [],
53
+ []
54
+ ],
55
+ "output": 826
56
+ },
57
+ {
58
+ "input": [
59
+ 13,
60
+ 7,
61
+ [],
62
+ []
63
+ ],
64
+ "output": 4489
65
+ },
66
+ {
67
+ "input": [
68
+ 18,
69
+ 20,
70
+ [],
71
+ []
72
+ ],
73
+ "output": 9671
74
+ },
75
+ {
76
+ "input": [
77
+ 8,
78
+ 17,
79
+ [],
80
+ []
81
+ ],
82
+ "output": 4105
83
+ },
84
+ {
85
+ "input": [
86
+ 17,
87
+ 17,
88
+ [],
89
+ []
90
+ ],
91
+ "output": 11577
92
+ },
93
+ {
94
+ "input": [
95
+ 16,
96
+ 7,
97
+ [],
98
+ []
99
+ ],
100
+ "output": 5144
101
+ },
102
+ {
103
+ "input": [
104
+ 11,
105
+ 9,
106
+ [],
107
+ []
108
+ ],
109
+ "output": 3790
110
+ }
111
+ ],
112
+ "haskell_template": "minimumCost :: Int -> Int -> [Int] -> [Int] -> Int\nminimumCost m n horizontalCut verticalCut ",
113
+ "ocaml_template": "let minimumCost (m: int) (n: int) (horizontalCut: int list) (verticalCut: int list) : int = ",
114
+ "scala_template": "def minimumCost(m: Int,n: Int,horizontalCut: List[Int],verticalCut: List[Int]): Int = { \n \n}",
115
+ "java_template": "class Solution {\n public int minimumCost(int m, int n, int[] horizontalCut, int[] verticalCut) {\n \n }\n}",
116
+ "python_template": "class Solution(object):\n def minimumCost(self, m, n, horizontalCut, verticalCut):\n \"\"\"\n :type m: int\n :type n: int\n :type horizontalCut: List[int]\n :type verticalCut: List[int]\n :rtype: int\n \"\"\"\n "
117
+ }
minimum_cost_for_cutting_cake_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 13 (minimumCost 3 2 [1;3] [5])
12
+
13
+ let test2 _ = assert_equal 15 (minimumCost 2 2 [7] [4])
14
+
15
+ let test3 _ = assert_equal 7332 (minimumCost 9 19 [] [])
16
+
17
+ let test4 _ = assert_equal 9876 (minimumCost 13 20 [] [])
18
+
19
+ let test5 _ = assert_equal 815 (minimumCost 1 14 [] [])
20
+
21
+ let test6 _ = assert_equal 826 (minimumCost 15 1 [] [])
22
+
23
+ let test7 _ = assert_equal 4489 (minimumCost 13 7 [] [])
24
+
25
+ let test8 _ = assert_equal 9671 (minimumCost 18 20 [] [])
26
+
27
+ let test9 _ = assert_equal 4105 (minimumCost 8 17 [] [])
28
+
29
+ let test10 _ = assert_equal 11577 (minimumCost 17 17 [] [])
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minimumCost" >::: [
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_cost_for_cutting_cake_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumCost(3,2,List(1,3),List(5)), 13)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumCost(2,2,List(7),List(4)), 15)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumCost(9,19,List(),List()), 7332)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumCost(13,20,List(),List()), 9876)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumCost(1,14,List(),List()), 815)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumCost(15,1,List(),List()), 826)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumCost(13,7,List(),List()), 4489)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumCost(18,20,List(),List()), 9671)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumCost(8,17,List(),List()), 4105)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumCost(17,17,List(),List()), 11577)
42
+ }
43
+
44
+ }
minimum_cost_for_cutting_cake_ii/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 (minimumCost 3 2 [1,3] [5])," 13 (minimumCost 3 2 [1,3] [5]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumCost 2 2 [7] [4])," 15 (minimumCost 2 2 [7] [4]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumCost 89625 86605 [] [])," 270184373677 (minimumCost 89625 86605 [] []))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minimumCost 24520 74173 [] [])," 63056735664 (minimumCost 24520 74173 [] []))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minimumCost 86957 32234 [] [])," 97433797491 (minimumCost 86957 32234 [] []))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minimumCost 85068 26951 [] [])," 79683655056 (minimumCost 85068 26951 [] []))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minimumCost 9975 93053 [] [])," 32327998720 (minimumCost 9975 93053 [] []))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minimumCost 32757 15609 [] [])," 17891510836 (minimumCost 32757 15609 [] []))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minimumCost 11492 52523 [] [])," 21084351324 (minimumCost 11492 52523 [] []))
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_cost_for_cutting_cake_ii/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(13, minimumCost(3, 2, new ArrayList<>(Arrays.asList(1,3)), new ArrayList<>(Arrays.asList(5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(15, minimumCost(2, 2, new ArrayList<>(Arrays.asList(7)), new ArrayList<>(Arrays.asList(4))));
19
+ }
20
+
21
+ }
minimum_cost_for_cutting_cake_ii/meta.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3500,
3
+ "name": "minimum_cost_for_cutting_cake_ii",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-ii/",
6
+ "date": "2024-07-07 00:00:00",
7
+ "task_description": "There is an `m x n` cake that needs to be cut into `1 x 1` pieces. You are given integers `m`, `n`, and two arrays: `horizontalCut` of size `m - 1`, where `horizontalCut[i]` represents the cost to cut along the horizontal line `i`. `verticalCut` of size `n - 1`, where `verticalCut[j]` represents the cost to cut along the vertical line `j`. In one operation, you can choose any piece of cake that is not yet a `1 x 1` square and perform one of the following cuts: Cut along a horizontal line `i` at a cost of `horizontalCut[i]`. Cut along a vertical line `j` at a cost of `verticalCut[j]`. After the cut, the piece of cake is divided into two distinct pieces. The cost of a cut depends only on the initial cost of the line and does not change. Return the **minimum** total cost to cut the entire cake into `1 x 1` pieces. **Example 1:** **Input:** m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5] **Output:** 13 **Explanation:** Perform a cut on the vertical line 0 with cost 5, current total cost is 5. Perform a cut on the horizontal line 0 on `3 x 1` subgrid with cost 1. Perform a cut on the horizontal line 0 on `3 x 1` subgrid with cost 1. Perform a cut on the horizontal line 1 on `2 x 1` subgrid with cost 3. Perform a cut on the horizontal line 1 on `2 x 1` subgrid with cost 3. The total cost is `5 + 1 + 1 + 3 + 3 = 13`. **Example 2:** **Input:** m = 2, n = 2, horizontalCut = [7], verticalCut = [4] **Output:** 15 **Explanation:** Perform a cut on the horizontal line 0 with cost 7. Perform a cut on the vertical line 0 on `1 x 2` subgrid with cost 4. Perform a cut on the vertical line 0 on `1 x 2` subgrid with cost 4. The total cost is `7 + 4 + 4 = 15`. **Constraints:** `1 <= m, n <= 105` `horizontalCut.length == m - 1` `verticalCut.length == n - 1` `1 <= horizontalCut[i], verticalCut[i] <= 103`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5]",
12
+ "output": "13 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "m = 2, n = 2, horizontalCut = [7], verticalCut = [4]",
17
+ "output": "15 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 89625,
24
+ 86605,
25
+ [],
26
+ []
27
+ ],
28
+ "output": 270184373677
29
+ },
30
+ {
31
+ "input": [
32
+ 24520,
33
+ 74173,
34
+ [],
35
+ []
36
+ ],
37
+ "output": 63056735664
38
+ },
39
+ {
40
+ "input": [
41
+ 86957,
42
+ 32234,
43
+ [],
44
+ []
45
+ ],
46
+ "output": 97433797491
47
+ },
48
+ {
49
+ "input": [
50
+ 85068,
51
+ 26951,
52
+ [],
53
+ []
54
+ ],
55
+ "output": 79683655056
56
+ },
57
+ {
58
+ "input": [
59
+ 9975,
60
+ 93053,
61
+ [],
62
+ []
63
+ ],
64
+ "output": 32327998720
65
+ },
66
+ {
67
+ "input": [
68
+ 32757,
69
+ 15609,
70
+ [],
71
+ []
72
+ ],
73
+ "output": 17891510836
74
+ },
75
+ {
76
+ "input": [
77
+ 11492,
78
+ 52523,
79
+ [],
80
+ []
81
+ ],
82
+ "output": 21084351324
83
+ },
84
+ {
85
+ "input": [
86
+ 84008,
87
+ 3918,
88
+ [],
89
+ []
90
+ ],
91
+ "output": 11524807547
92
+ },
93
+ {
94
+ "input": [
95
+ 73955,
96
+ 16674,
97
+ [],
98
+ []
99
+ ],
100
+ "output": 42937148241
101
+ },
102
+ {
103
+ "input": [
104
+ 30041,
105
+ 32034,
106
+ [],
107
+ []
108
+ ],
109
+ "output": 33349734393
110
+ }
111
+ ],
112
+ "haskell_template": "minimumCost :: Int -> Int -> [Int] -> [Int] -> Int\nminimumCost m n horizontalCut verticalCut ",
113
+ "ocaml_template": "let minimumCost (m: int) (n: int) (horizontalCut: int list) (verticalCut: int list) : int = ",
114
+ "scala_template": "def minimumCost(m: Int,n: Int,horizontalCut: List[Int],verticalCut: List[Int]): Int = { \n \n}",
115
+ "java_template": "class Solution {\n public long minimumCost(int m, int n, int[] horizontalCut, int[] verticalCut) {\n \n }\n}",
116
+ "python_template": "class Solution(object):\n def minimumCost(self, m, n, horizontalCut, verticalCut):\n \"\"\"\n :type m: int\n :type n: int\n :type horizontalCut: List[int]\n :type verticalCut: List[int]\n :rtype: int\n \"\"\"\n "
117
+ }
minimum_cost_for_cutting_cake_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 13 (minimumCost 3 2 [1;3] [5])
12
+
13
+ let test2 _ = assert_equal 15 (minimumCost 2 2 [7] [4])
14
+
15
+ let test3 _ = assert_equal 270184373677 (minimumCost 89625 86605 [] [])
16
+
17
+ let test4 _ = assert_equal 63056735664 (minimumCost 24520 74173 [] [])
18
+
19
+ let test5 _ = assert_equal 97433797491 (minimumCost 86957 32234 [] [])
20
+
21
+ let test6 _ = assert_equal 79683655056 (minimumCost 85068 26951 [] [])
22
+
23
+ let test7 _ = assert_equal 32327998720 (minimumCost 9975 93053 [] [])
24
+
25
+ let test8 _ = assert_equal 17891510836 (minimumCost 32757 15609 [] [])
26
+
27
+ let test9 _ = assert_equal 21084351324 (minimumCost 11492 52523 [] [])
28
+
29
+ let test10 _ = assert_equal 11524807547 (minimumCost 84008 3918 [] [])
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minimumCost" >::: [
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_cost_for_cutting_cake_ii/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumCost(3,2,List(1,3),List(5)), 13)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumCost(2,2,List(7),List(4)), 15)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumCost(89625,86605,List(),List()), BigInt("270184373677"))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumCost(24520,74173,List(),List()), BigInt("63056735664"))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumCost(86957,32234,List(),List()), BigInt("97433797491"))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumCost(85068,26951,List(),List()), BigInt("79683655056"))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumCost(9975,93053,List(),List()), BigInt("32327998720"))
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumCost(32757,15609,List(),List()), BigInt("17891510836"))
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumCost(11492,52523,List(),List()), BigInt("21084351324"))
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumCost(84008,3918,List(),List()), BigInt("11524807547"))
42
+ }
43
+
44
+ }
minimum_cost_good_caption/haskell_tests/Main.hs ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minCostGoodCaption :: String -> String
7
+ minCostGoodCaption caption = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minCostGoodCaption \"cdcd \")," "cccc" (minCostGoodCaption "cdcd"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minCostGoodCaption \"aca \")," "aaa" (minCostGoodCaption "aca"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minCostGoodCaption \"bc \")," "" (minCostGoodCaption "bc"))
21
+
22
+
23
+ -- Grouping test cases
24
+ tests :: Test
25
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
26
+
27
+ -- Running the tests
28
+ main :: IO Counts
29
+ main = runTestTT tests
minimum_cost_good_caption/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("cdcd", minCostGoodCaption("cdcd"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("aca", minCostGoodCaption("aca"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals("bc", minCostGoodCaption("bc"));
22
+ }
23
+
24
+ }
minimum_cost_good_caption/meta.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3701,
3
+ "name": "minimum_cost_good_caption",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/minimum-cost-good-caption/",
6
+ "date": "2025-01-18 00:00:00",
7
+ "task_description": "You are given a string `caption` of length `n`. A **good** caption is a string where **every** character appears in groups of **at least 3** consecutive occurrences. For example: `\"aaabbb\"` and `\"aaaaccc\"` are **good** captions. `\"aabbb\"` and `\"ccccd\"` are **not** good captions. You can perform the following operation **any** number of times: Choose an index `i` (where `0 <= i < n`) and change the character at that index to either: The character immediately **before** it in the alphabet (if `caption[i] != 'a'`). The character immediately **after** it in the alphabet (if `caption[i] != 'z'`). Your task is to convert the given `caption` into a **good** caption using the **minimum** number of operations, and return it. If there are **multiple** possible good captions, return the **lexicographically smallest** one among them. If it is **impossible** to create a good caption, return an empty string `\"\"`. **Example 1:** **Input:** caption = \"cdcd\" **Output:** \"cccc\" **Explanation:** It can be shown that the given caption cannot be transformed into a good caption with fewer than 2 operations. The possible good captions that can be created using exactly 2 operations are: `\"dddd\"`: Change `caption[0]` and `caption[2]` to their next character `'d'`. `\"cccc\"`: Change `caption[1]` and `caption[3]` to their previous character `'c'`. Since `\"cccc\"` is lexicographically smaller than `\"dddd\"`, return `\"cccc\"`. **Example 2:** **Input:** caption = \"aca\" **Output:** \"aaa\" **Explanation:** It can be proven that the given caption requires at least 2 operations to be transformed into a good caption. The only good caption that can be obtained with exactly 2 operations is as follows: Operation 1: Change `caption[1]` to `'b'`. `caption = \"aba\"`. Operation 2: Change `caption[1]` to `'a'`. `caption = \"aaa\"`. Thus, return `\"aaa\"`. **Example 3:** **Input:** caption = \"bc\" **Output:** \"\" **Explanation:** It can be shown that the given caption cannot be converted to a good caption by using any number of operations. **Constraints:** `1 <= caption.length <= 5 * 104` `caption` consists only of lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "caption = \"cdcd\"",
12
+ "output": "\"cccc\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "caption = \"aca\"",
17
+ "output": "\"aaa\" "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "caption = \"bc\"",
22
+ "output": "\"\" "
23
+ }
24
+ ],
25
+ "private_test_cases": [],
26
+ "haskell_template": "minCostGoodCaption :: String -> String\nminCostGoodCaption caption ",
27
+ "ocaml_template": "let minCostGoodCaption (caption: string) : string = ",
28
+ "scala_template": "def minCostGoodCaption(caption: String): String = { \n \n}",
29
+ "java_template": "class Solution {\n public String minCostGoodCaption(String caption) {\n \n }\n}",
30
+ "python_template": "class Solution(object):\n def minCostGoodCaption(self, caption):\n \"\"\"\n :type caption: str\n :rtype: str\n \"\"\"\n "
31
+ }
minimum_cost_good_caption/ocaml_tests/main.ml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minCostGoodCaption (caption: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "cccc" (minCostGoodCaption "cdcd")
13
+
14
+ let test2 _ = assert_equal "aaa" (minCostGoodCaption "aca")
15
+
16
+ let test3 _ = assert_equal "" (minCostGoodCaption "bc")
17
+
18
+
19
+ (* Grouping test cases *)
20
+ let suite = "Test Suite for minCostGoodCaption" >::: [
21
+
22
+ "test1" >:: test1;
23
+ "test2" >:: test2;
24
+ "test3" >:: test3;
25
+ ]
26
+
27
+
28
+ (* Running the tests *)
29
+ let () = run_test_tt_main suite
30
+ end
minimum_cost_good_caption/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minCostGoodCaption("cdcd"), "cccc")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minCostGoodCaption("aca"), "aaa")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minCostGoodCaption("bc"), "")
14
+ }
15
+
16
+ }