DatasetRepo commited on
Commit
b677a2e
·
verified ·
1 Parent(s): 0bc0f17

6b09971df99a3b60672b21b6294001be8734c1264de3a1c37cb0dffe06141536

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. min_max_game/scala_tests/MySuite.scala +32 -0
  3. minimize_length_of_array_using_operations/haskell_tests/Main.hs +0 -0
  4. minimize_length_of_array_using_operations/java_tests/Main.java +24 -0
  5. minimize_length_of_array_using_operations/meta.json +0 -0
  6. minimize_length_of_array_using_operations/ocaml_tests/main.ml +0 -0
  7. minimize_length_of_array_using_operations/scala_tests/MySuite.scala +0 -0
  8. minimize_manhattan_distances/haskell_tests/Main.hs +0 -0
  9. minimize_manhattan_distances/java_tests/Main.java +20 -0
  10. minimize_manhattan_distances/meta.json +0 -0
  11. minimize_manhattan_distances/ocaml_tests/main.ml +0 -0
  12. minimize_manhattan_distances/scala_tests/MySuite.scala +0 -0
  13. minimize_maximum_of_array/.DS_Store +0 -0
  14. minimize_maximum_of_array/haskell_tests/Main.hs +24 -0
  15. minimize_maximum_of_array/java_tests/Main.java +21 -0
  16. minimize_maximum_of_array/meta.json +3 -0
  17. minimize_maximum_of_array/ocaml_tests/main.ml +26 -0
  18. minimize_maximum_of_array/scala_tests/MySuite.scala +12 -0
  19. minimize_or_of_remaining_elements_using_operations/haskell_tests/Main.hs +0 -0
  20. minimize_or_of_remaining_elements_using_operations/java_tests/Main.java +25 -0
  21. minimize_or_of_remaining_elements_using_operations/meta.json +3 -0
  22. minimize_or_of_remaining_elements_using_operations/ocaml_tests/main.ml +0 -0
  23. minimize_or_of_remaining_elements_using_operations/scala_tests/MySuite.scala +0 -0
  24. minimize_result_by_adding_parentheses_to_expression/.DS_Store +0 -0
  25. minimize_result_by_adding_parentheses_to_expression/haskell_tests/Main.hs +27 -0
  26. minimize_result_by_adding_parentheses_to_expression/java_tests/Main.java +25 -0
  27. minimize_result_by_adding_parentheses_to_expression/meta.json +72 -0
  28. minimize_result_by_adding_parentheses_to_expression/ocaml_tests/main.ml +29 -0
  29. minimize_result_by_adding_parentheses_to_expression/scala_tests/MySuite.scala +16 -0
  30. minimize_string_length/haskell_tests/Main.hs +47 -0
  31. minimize_string_length/java_tests/Main.java +24 -0
  32. minimize_string_length/meta.json +72 -0
  33. minimize_string_length/ocaml_tests/main.ml +51 -0
  34. minimize_string_length/scala_tests/MySuite.scala +44 -0
  35. minimize_the_maximum_adjacent_element_difference/haskell_tests/Main.hs +0 -0
  36. minimize_the_maximum_adjacent_element_difference/java_tests/Main.java +24 -0
  37. minimize_the_maximum_adjacent_element_difference/meta.json +0 -0
  38. minimize_the_maximum_adjacent_element_difference/ocaml_tests/main.ml +0 -0
  39. minimize_the_maximum_adjacent_element_difference/scala_tests/MySuite.scala +0 -0
  40. minimize_the_maximum_difference_of_pairs/.DS_Store +0 -0
  41. minimize_the_maximum_difference_of_pairs/haskell_tests/Main.hs +24 -0
  42. minimize_the_maximum_difference_of_pairs/java_tests/Main.java +21 -0
  43. minimize_the_maximum_difference_of_pairs/meta.json +3 -0
  44. minimize_the_maximum_difference_of_pairs/ocaml_tests/main.ml +26 -0
  45. minimize_the_maximum_difference_of_pairs/scala_tests/MySuite.scala +12 -0
  46. minimize_the_maximum_edge_weight_of_graph/java_tests/Main.java +29 -0
  47. minimize_the_maximum_of_two_arrays/haskell_tests/Main.hs +45 -0
  48. minimize_the_maximum_of_two_arrays/java_tests/Main.java +25 -0
  49. minimize_the_maximum_of_two_arrays/meta.json +95 -0
  50. minimize_the_maximum_of_two_arrays/ocaml_tests/main.ml +50 -0
.gitattributes CHANGED
@@ -208,3 +208,6 @@ meta2/.DS_Store filter=lfs diff=lfs merge=lfs -text
208
  meta2/add_edges_to_make_degrees_of_all_nodes_even/meta.json filter=lfs diff=lfs merge=lfs -text
209
  meta2/all_divisions_with_the_highest_score_of_a_binary_array/meta.json filter=lfs diff=lfs merge=lfs -text
210
  mice_and_cheese/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
208
  meta2/add_edges_to_make_degrees_of_all_nodes_even/meta.json filter=lfs diff=lfs merge=lfs -text
209
  meta2/all_divisions_with_the_highest_score_of_a_binary_array/meta.json filter=lfs diff=lfs merge=lfs -text
210
  mice_and_cheese/meta.json filter=lfs diff=lfs merge=lfs -text
211
+ minimize_maximum_of_array/meta.json filter=lfs diff=lfs merge=lfs -text
212
+ minimize_or_of_remaining_elements_using_operations/meta.json filter=lfs diff=lfs merge=lfs -text
213
+ minimize_the_maximum_difference_of_pairs/meta.json filter=lfs diff=lfs merge=lfs -text
min_max_game/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minMaxGame(List(1,3,5,2,4,8,2,2)), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minMaxGame(List(3)), 3)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minMaxGame(115040532,691122985,74905644,691122985,74905644,488737920,409049507,691122985,74905644,424016316,139550887,488737920,409049507,778486804,581936863,691122985,74905644,898320970,424016316,316332152,322747948,139550887,10127500,488737920,409049507,714000633,529661213,778486804,581936863,766268468,256616097,691122985,893168349,74905644,898320970,562091841,623374598,424016316,316332152,175024652,322747948,421471664,139550887,27323869,10127500,285386703,54510532,488737920,920450369,409049507,714000633,376483632,529661213,689244382,749711836,778486804,581936863,952610726,46933645,766268468,256616097,930245976,109029077,691122985), 115040532)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minMaxGame(422752264,444626536,383451709,444626536,964694290,383451709,444626536,354937044), 422752264)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minMaxGame(347432181,347432181,347432181,253225415), 347432181)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minMaxGame(277872296,945927896,351536846,945927896,351536846,505308252,355276338,945927896,351536846,740924939,38550376,505308252,355276338,720623023,50265300,945927896,351536846,818710986,268024035,740924939,38550376,917469833,218828997,505308252,355276338,675186659,272427923,720623023,50265300,349134637,197930247,945927896,351536846,933128750,89429569,818710986,268024035,630711263,740924939,442693871,38550376,987228952,110075355,917469833,218828997,825822362,168084080,505308252,355276338,930388442,188207825,675186659,272427923,816044008,613681487,720623023,50265300,918806830,349134637,278273618,197930247,846327293,114080947,945927896,351536846,962339954,153247899,933128750,89429569,949890359,736501846,818710986,268024035,936649815,630711263,623451241,740924939,784006358,364968461,442693871,38550376,827637389,775002894,987228952,110075355,898363618,496412781,917469833,218828997,775423695,299108265,825822362,168084080,655056704,55736741,505308252,355276338,822549513,165382074,930388442,188207825,623202735,97039735,675186659,272427923,899139750,58820112,816044008,613681487,692107265,446140510,720623023,50265300,786653476,631607382,918806830,738179041,349134637,3081800,278273618,197930247,814391196,846327293,839751160,114080947,766307757,394016082,945927896,842046573,351536846,581539229,962339954,153247899,893052643,933128750,886264387,237453609,89429569,168548190,949890359,736501846,874536926,390388306,818710986,268024035,930890158,936649815,787292160,630711263,790680442,623451241,528577751,757668896,740924939,540340338,784006358,364968461,634924643,442693871,402084206,38550376,50388559,486527953,827637389,889740846,775002894,987228952,711758512,110075355,554558129,898363618,430338156,855273022,496412781,917469833,513275787,287567580,218828997,775423695,544183099,960564854,299108265,403334797,825822362,168084080,420433761,257316455,655056704,614047974,55736741,55437983,505308252,355276338,829117431,425539800,822549513,473149306,165382074,930388442,219356010,188207825,221601673,339915824,623202735,97039735,643265311,675186659,302235312,801212847,272427923,899139750,473530827,701114055,58820112,103017505,816044008,613681487,819740209,623887143,692107265,446140510,818007276,45103587,720623023,50265300,236708934,646052908,786653476,631607382,943759801,918806830,256451102,738179041,798967010,56615261,349134637,3081800,585996046,278273618,187195679,365793711,197930247,814391196,1711047,846327293,989073716,454322636,839751160,803562099,114080947,656466739,766307757,829671791,394016082,945927896,556552137), 277872296)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minMaxGame(439363306,983086361,18639521,983086361,18639521,926360015,429073836,983086361,18639521,618347797,331389171,926360015,429073836,823614485,206463919,983086361,18639521,551614501,528697263,618347797,729566617,331389171,806609119,926360015,429073836,906955449,28743328,823614485,575701114,206463919,430845510,983086361,18639521,476762353,551614501,483033277,528697263,757187572,618347797,289394534,930884662,729566617,331389171,248606565,828364048,806609119,104101301,926360015,586131558,429073836,124381100,906955449,871344524,28743328,372630435,823614485,575701114,898787203,206463919,11428664,430845510,479380797,101634865,983086361), 439363306)
30
+ }
31
+
32
+ }
minimize_length_of_array_using_operations/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimize_length_of_array_using_operations/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(1, minimumArrayLength(Arrays.asList(1,4,3,1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(2, minimumArrayLength(Arrays.asList(5,5,5,10,5)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(1, minimumArrayLength(Arrays.asList(2,3,4)));
22
+ }
23
+
24
+ }
minimize_length_of_array_using_operations/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimize_length_of_array_using_operations/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimize_length_of_array_using_operations/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimize_manhattan_distances/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimize_manhattan_distances/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(12, minimumDistance(Arrays.asList(Arrays.asList(3,10),Arrays.asList(5,15),Arrays.asList(10,2),Arrays.asList(4,4))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(0, minimumDistance(Arrays.asList(Arrays.asList(1,1),Arrays.asList(1,1),Arrays.asList(1,1))));
18
+ }
19
+
20
+ }
minimize_manhattan_distances/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimize_manhattan_distances/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimize_manhattan_distances/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimize_maximum_of_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimize_maximum_of_array/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 (minimizeArrayValue [3,7,1,6])," 5 (minimizeArrayValue [3,7,1,6]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimizeArrayValue [10,1])," 10 (minimizeArrayValue [10,1]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
minimize_maximum_of_array/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(5, minimizeArrayValue(new ArrayList<>(Arrays.asList(3,7,1,6))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(10, minimizeArrayValue(new ArrayList<>(Arrays.asList(10,1))));
19
+ }
20
+
21
+ }
minimize_maximum_of_array/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50ddded2beb62c5a4d37c29d1cedc26be79d16808037812fbdac1bcdb803fefe
3
+ size 17235426
minimize_maximum_of_array/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 5 (minimizeArrayValue [3;7;1;6])
12
+
13
+ let test2 _ = assert_equal 10 (minimizeArrayValue [10;1])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimizeArrayValue" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimize_maximum_of_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimizeArrayValue(List(3,7,1,6)), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimizeArrayValue(List(10,1)), 10)
10
+ }
11
+
12
+ }
minimize_or_of_remaining_elements_using_operations/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimize_or_of_remaining_elements_using_operations/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(3, minOrAfterOperations(new ArrayList<>(Arrays.asList(3,5,3,2,7)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, minOrAfterOperations(new ArrayList<>(Arrays.asList(7,3,15,14,2,8)), 4));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(15, minOrAfterOperations(new ArrayList<>(Arrays.asList(10,7,10,3,9,14,9,4)), 1));
23
+ }
24
+
25
+ }
minimize_or_of_remaining_elements_using_operations/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd49ffae055782dd0d8e0c8f0d0874961308148e31b35d761148f91669cc404e
3
+ size 11643375
minimize_or_of_remaining_elements_using_operations/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimize_or_of_remaining_elements_using_operations/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimize_result_by_adding_parentheses_to_expression/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimize_result_by_adding_parentheses_to_expression/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 (minimizeResult \"247+38 \")," "2(47+38)" (minimizeResult "247+38"))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimizeResult \"12+34 \")," "1(2+3)4" (minimizeResult "12+34"))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimizeResult \"999+999 \")," "(999+999)" (minimizeResult "999+999"))
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
minimize_result_by_adding_parentheses_to_expression/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("247+38", minimizeResult("247+38"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("12+34", minimizeResult("12+34"));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals("999+999", minimizeResult("999+999"));
23
+ }
24
+
25
+ }
minimize_result_by_adding_parentheses_to_expression/meta.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2328,
3
+ "name": "minimize_result_by_adding_parentheses_to_expression",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/minimize-result-by-adding-parentheses-to-expression/",
6
+ "date": "1648944000000",
7
+ "task_description": "You are given a **0-indexed** string `expression` of the form `\"<num1>+<num2>\"` where `<num1>` and `<num2>` represent positive integers. Add a pair of parentheses to `expression` such that after the addition of parentheses, `expression` is a **valid** mathematical expression and evaluates to the **smallest** possible value. The left parenthesis **must** be added to the left of `'+'` and the right parenthesis **must** be added to the right of `'+'`. Return `expression`_ after adding a pair of parentheses such that _`expression`_ evaluates to the **smallest** possible value._ If there are multiple answers that yield the same result, return any of them. The input has been generated such that the original value of `expression`, and the value of `expression` after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer. **Example 1:** ``` **Input:** expression = \"247+38\" **Output:** \"2(47+38)\" **Explanation:** The `expression` evaluates to 2 * (47 + 38) = 2 * 85 = 170. Note that \"2(4)7+38\" is invalid because the right parenthesis must be to the right of the `'+'`. It can be shown that 170 is the smallest possible value. ``` **Example 2:** ``` **Input:** expression = \"12+34\" **Output:** \"1(2+3)4\" **Explanation:** The expression evaluates to 1 * (2 + 3) * 4 = 1 * 5 * 4 = 20. ``` **Example 3:** ``` **Input:** expression = \"999+999\" **Output:** \"(999+999)\" **Explanation:** The `expression` evaluates to 999 + 999 = 1998. ``` **Constraints:** `3 <= expression.length <= 10` `expression` consists of digits from `'1'` to `'9'` and `'+'`. `expression` starts and ends with digits. `expression` contains exactly one `'+'`. The original value of `expression`, and the value of `expression` after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "expression = \"247+38\"",
12
+ "output": "\"2(47+38)\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "expression = \"12+34\"",
17
+ "output": "\"1(2+3)4\" "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "expression = \"999+999\"",
22
+ "output": "\"(999+999)\" "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": "69+1",
28
+ "output": "6(9+1)"
29
+ },
30
+ {
31
+ "input": "5+57888",
32
+ "output": "(5+5788)8"
33
+ },
34
+ {
35
+ "input": "2281+9868",
36
+ "output": "(2281+9868)"
37
+ },
38
+ {
39
+ "input": "718+2",
40
+ "output": "7(18+2)"
41
+ },
42
+ {
43
+ "input": "9+1776",
44
+ "output": "(9+177)6"
45
+ },
46
+ {
47
+ "input": "75+59239",
48
+ "output": "(75+592)39"
49
+ },
50
+ {
51
+ "input": "2+925",
52
+ "output": "(2+9)25"
53
+ },
54
+ {
55
+ "input": "3347+15",
56
+ "output": "3(347+15)"
57
+ },
58
+ {
59
+ "input": "89337+98",
60
+ "output": "89(337+98)"
61
+ },
62
+ {
63
+ "input": "376+635",
64
+ "output": "(376+635)"
65
+ }
66
+ ],
67
+ "haskell_template": "minimizeResult :: String -> String\nminimizeResult expression ",
68
+ "ocaml_template": "let minimizeResult (expression: string) : string = ",
69
+ "scala_template": "def minimizeResult(expression: String): String = { \n \n}",
70
+ "java_template": "public static String minimizeResult(String expression) {\n\n}",
71
+ "python_template": "class Solution(object):\n def minimizeResult(self, expression):\n \"\"\"\n :type expression: str\n :rtype: str\n \"\"\"\n "
72
+ }
minimize_result_by_adding_parentheses_to_expression/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 "2(47+38)" (minimizeResult "247+38")
12
+
13
+ let test2 _ = assert_equal "1(2+3)4" (minimizeResult "12+34")
14
+
15
+ let test3 _ = assert_equal "(999+999)" (minimizeResult "999+999")
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for minimizeResult" >::: [
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
minimize_result_by_adding_parentheses_to_expression/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimizeResult("247+38"), "2(47+38)")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimizeResult("12+34"), "1(2+3)4")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimizeResult("999+999"), "(999+999)")
14
+ }
15
+
16
+ }
minimize_string_length/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimizedStringLength :: String -> Int
7
+ minimizedStringLength s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimizedStringLength \"aaabc \")," 3 (minimizedStringLength "aaabc"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimizedStringLength \"cbbd \")," 3 (minimizedStringLength "cbbd"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimizedStringLength \"baadccab \")," 4 (minimizedStringLength "baadccab"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimizedStringLength \"tcvpsshshoempgosrmzprwdcqyjxtubmrctsxiplwhdnvnzl \")," 23 (minimizedStringLength "tcvpsshshoempgosrmzprwdcqyjxtubmrctsxiplwhdnvnzl"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimizedStringLength \"zbdiihopkvppoyujbpqwlazodrulomflmeektpolhnlinorgkoabhesiufhjxyouoayxffbs \")," 25 (minimizedStringLength "zbdiihopkvppoyujbpqwlazodrulomflmeektpolhnlinorgkoabhesiufhjxyouoayxffbs"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimizedStringLength \"bfregovatvtfocylmcrvldljokensrvtuasjblfrppljuafmpanfvdvjmhijjzrevithz \")," 23 (minimizedStringLength "bfregovatvtfocylmcrvldljokensrvtuasjblfrppljuafmpanfvdvjmhijjzrevithz"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimizedStringLength \"daokppkqwypwzrcyoxpqayzqabuxbgafmehmrmcqpowltebbzcqkgxndvblvnrxatq \")," 23 (minimizedStringLength "daokppkqwypwzrcyoxpqayzqabuxbgafmehmrmcqpowltebbzcqkgxndvblvnrxatq"))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (minimizedStringLength \"wqrl \")," 4 (minimizedStringLength "wqrl"))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (minimizedStringLength \"bprwvtx \")," 7 (minimizedStringLength "bprwvtx"))
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
minimize_string_length/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(3, minimizedStringLength("aaabc"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(3, minimizedStringLength("cbbd"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(4, minimizedStringLength("baadccab"));
22
+ }
23
+
24
+ }
minimize_string_length/meta.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2825,
3
+ "name": "minimize_string_length",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimize-string-length/",
6
+ "date": "2023-05-28 00:00:00",
7
+ "task_description": "Given a string `s`, you have two types of operation: Choose an index `i` in the string, and let `c` be the character in position `i`. **Delete** the **closest occurrence** of `c` to the **left** of `i` (if exists). Choose an index `i` in the string, and let `c` be the character in position `i`. **Delete** the **closest occurrence** of `c` to the **right** of `i` (if exists). Your task is to **minimize** the length of `s` by performing the above operations zero or more times. Return an integer denoting the length of the **minimized** string. **Example 1:** **Input:** s = \"aaabc\" **Output:** 3 **Explanation:** Operation 2: we choose `i = 1` so `c` is 'a', then we remove `s[2]` as it is closest 'a' character to the right of `s[1]`. `s` becomes \"aabc\" after this. Operation 1: we choose `i = 1` so `c` is 'a', then we remove `s[0]` as it is closest 'a' character to the left of `s[1]`. `s` becomes \"abc\" after this. **Example 2:** **Input:** s = \"cbbd\" **Output:** 3 **Explanation:** Operation 1: we choose `i = 2` so `c` is 'b', then we remove `s[1]` as it is closest 'b' character to the left of `s[1]`. `s` becomes \"cbd\" after this. **Example 3:** **Input:** s = \"baadccab\" **Output:** 4 **Explanation:** Operation 1: we choose `i = 6` so `c` is 'a', then we remove `s[2]` as it is closest 'a' character to the left of `s[6]`. `s` becomes \"badccab\" after this. Operation 2: we choose `i = 0` so `c` is 'b', then we remove `s[6]` as it is closest 'b' character to the right of `s[0]`. `s` becomes \"badcca\" fter this. Operation 2: we choose `i = 3` so `c` is 'c', then we remove `s[4]` as it is closest 'c' character to the right of `s[3]`. `s` becomes \"badca\" after this. Operation 1: we choose `i = 4` so `c` is 'a', then we remove `s[1]` as it is closest 'a' character to the left of `s[4]`. `s` becomes \"bdca\" after this. **Constraints:** `1 <= s.length <= 100` `s` contains only lowercase English letters",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"aaabc\"",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"cbbd\"",
17
+ "output": "3 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "s = \"baadccab\"",
22
+ "output": "4 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": "tcvpsshshoempgosrmzprwdcqyjxtubmrctsxiplwhdnvnzl",
28
+ "output": 23
29
+ },
30
+ {
31
+ "input": "zbdiihopkvppoyujbpqwlazodrulomflmeektpolhnlinorgkoabhesiufhjxyouoayxffbs",
32
+ "output": 25
33
+ },
34
+ {
35
+ "input": "bfregovatvtfocylmcrvldljokensrvtuasjblfrppljuafmpanfvdvjmhijjzrevithz",
36
+ "output": 23
37
+ },
38
+ {
39
+ "input": "daokppkqwypwzrcyoxpqayzqabuxbgafmehmrmcqpowltebbzcqkgxndvblvnrxatq",
40
+ "output": 23
41
+ },
42
+ {
43
+ "input": "wqrl",
44
+ "output": 4
45
+ },
46
+ {
47
+ "input": "bprwvtx",
48
+ "output": 7
49
+ },
50
+ {
51
+ "input": "dvfhbqdwlneugchiwabnoirgaocunopshqpgldaxfmiihp",
52
+ "output": 21
53
+ },
54
+ {
55
+ "input": "gubdzicnxwzcufaeuuqxwxwyhmabtrbnritwhqulfdybxupchiqafwflmvqztiqdaaimqzhpwmkjek",
56
+ "output": 24
57
+ },
58
+ {
59
+ "input": "nmhzxfmnystrhyxclscmayjaxpwzndtnxdlseuyrkwmbumqrowyskalqpvsjexibbt",
60
+ "output": 25
61
+ },
62
+ {
63
+ "input": "ujkydxn",
64
+ "output": 7
65
+ }
66
+ ],
67
+ "haskell_template": "minimizedStringLength :: String -> Int\nminimizedStringLength s ",
68
+ "ocaml_template": "let minimizedStringLength (s: string) : int = ",
69
+ "scala_template": "def minimizedStringLength(s: String): Int = { \n \n}",
70
+ "java_template": "class Solution {\n public int minimizedStringLength(String s) {\n \n }\n}",
71
+ "python_template": "class Solution(object):\n def minimizedStringLength(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "
72
+ }
minimize_string_length/ocaml_tests/main.ml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimizedStringLength (s: string) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 3 (minimizedStringLength "aaabc")
13
+
14
+ let test2 _ = assert_equal 3 (minimizedStringLength "cbbd")
15
+
16
+ let test3 _ = assert_equal 4 (minimizedStringLength "baadccab")
17
+
18
+ let test4 _ = assert_equal 4 (minimizedStringLength "tcvpsshshoempgosrmzprwdcqyjxtubmrctsxiplwhdnvnzl")
19
+
20
+ let test5 _ = assert_equal 4 (minimizedStringLength "zbdiihopkvppoyujbpqwlazodrulomflmeektpolhnlinorgkoabhesiufhjxyouoayxffbs")
21
+
22
+ let test6 _ = assert_equal 4 (minimizedStringLength "bfregovatvtfocylmcrvldljokensrvtuasjblfrppljuafmpanfvdvjmhijjzrevithz")
23
+
24
+ let test7 _ = assert_equal 4 (minimizedStringLength "daokppkqwypwzrcyoxpqayzqabuxbgafmehmrmcqpowltebbzcqkgxndvblvnrxatq")
25
+
26
+ let test8 _ = assert_equal 4 (minimizedStringLength "wqrl")
27
+
28
+ let test9 _ = assert_equal 4 (minimizedStringLength "bprwvtx")
29
+
30
+ let test10 _ = assert_equal 4 (minimizedStringLength "dvfhbqdwlneugchiwabnoirgaocunopshqpgldaxfmiihp")
31
+
32
+
33
+ (* Grouping test cases *)
34
+ let suite = "Test Suite for minimizedStringLength" >::: [
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
minimize_string_length/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimizedStringLength("aaabc"), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimizedStringLength("cbbd"), 3)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimizedStringLength("baadccab"), 4)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimizedStringLength(",t,c,v,p,s,s,h,s,h,o,e,m,p,g,o,s,r,m,z,p,r,w,d,c,q,y,j,x,t,u,b,m,r,c,t,s,x,i,p,l,w,h,d,n,v,n,z,l,"), 23)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimizedStringLength(",z,b,d,i,i,h,o,p,k,v,p,p,o,y,u,j,b,p,q,w,l,a,z,o,d,r,u,l,o,m,f,l,m,e,e,k,t,p,o,l,h,n,l,i,n,o,r,g,k,o,a,b,h,e,s,i,u,f,h,j,x,y,o,u,o,a,y,x,f,f,b,s,"), 25)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimizedStringLength(",b,f,r,e,g,o,v,a,t,v,t,f,o,c,y,l,m,c,r,v,l,d,l,j,o,k,e,n,s,r,v,t,u,a,s,j,b,l,f,r,p,p,l,j,u,a,f,m,p,a,n,f,v,d,v,j,m,h,i,j,j,z,r,e,v,i,t,h,z,"), 23)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimizedStringLength(",d,a,o,k,p,p,k,q,w,y,p,w,z,r,c,y,o,x,p,q,a,y,z,q,a,b,u,x,b,g,a,f,m,e,h,m,r,m,c,q,p,o,w,l,t,e,b,b,z,c,q,k,g,x,n,d,v,b,l,v,n,r,x,a,t,q,"), 23)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimizedStringLength(",w,q,r,l,"), 4)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimizedStringLength(",b,p,r,w,v,t,x,"), 7)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimizedStringLength(",d,v,f,h,b,q,d,w,l,n,e,u,g,c,h,i,w,a,b,n,o,i,r,g,a,o,c,u,n,o,p,s,h,q,p,g,l,d,a,x,f,m,i,i,h,p,"), 21)
42
+ }
43
+
44
+ }
minimize_the_maximum_adjacent_element_difference/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimize_the_maximum_adjacent_element_difference/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(4, minDifference(Arrays.asList(1,2,-1,10,8)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(0, minDifference(Arrays.asList(-1,-1,-1)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(1, minDifference(Arrays.asList(-1,10,-1,8)));
22
+ }
23
+
24
+ }
minimize_the_maximum_adjacent_element_difference/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimize_the_maximum_adjacent_element_difference/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimize_the_maximum_adjacent_element_difference/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimize_the_maximum_difference_of_pairs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimize_the_maximum_difference_of_pairs/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (minimizeMax [10,1,2,7,1,3] 2)," 1 (minimizeMax [10,1,2,7,1,3] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimizeMax [4,2,1,2] 1)," 0 (minimizeMax [4,2,1,2] 1))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
minimize_the_maximum_difference_of_pairs/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(1, minimizeMax(new ArrayList<>(Arrays.asList(10,1,2,7,1,3)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, minimizeMax(new ArrayList<>(Arrays.asList(4,2,1,2)), 1));
19
+ }
20
+
21
+ }
minimize_the_maximum_difference_of_pairs/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dcdc0338261dcea0e49878986f84e9545d135d00bc4d0d228164e99cbf00ae8
3
+ size 19234547
minimize_the_maximum_difference_of_pairs/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 1 (minimizeMax [10;1;2;7;1;3] 2)
12
+
13
+ let test2 _ = assert_equal 0 (minimizeMax [4;2;1;2] 1)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for minimizeMax" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
minimize_the_maximum_difference_of_pairs/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimizeMax(List(10,1,2,7,1,3),2), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimizeMax(List(4,2,1,2),1), 0)
10
+ }
11
+
12
+ }
minimize_the_maximum_edge_weight_of_graph/java_tests/Main.java ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, minMaxWeight(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,0,1)),new ArrayList<>(Arrays.asList(2,0,2)),new ArrayList<>(Arrays.asList(3,0,1)),new ArrayList<>(Arrays.asList(4,3,1)),new ArrayList<>(Arrays.asList(2,1,1)))), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, minMaxWeight(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1,1)),new ArrayList<>(Arrays.asList(0,2,2)),new ArrayList<>(Arrays.asList(0,3,1)),new ArrayList<>(Arrays.asList(0,4,1)),new ArrayList<>(Arrays.asList(1,2,1)),new ArrayList<>(Arrays.asList(1,4,1)))), 1));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(2, minMaxWeight(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,1)),new ArrayList<>(Arrays.asList(1,3,3)),new ArrayList<>(Arrays.asList(1,4,5)),new ArrayList<>(Arrays.asList(2,3,2)),new ArrayList<>(Arrays.asList(3,4,2)),new ArrayList<>(Arrays.asList(4,0,1)))), 1));
23
+ }
24
+ @Test
25
+ public void test4() {
26
+ assertEquals(-, minMaxWeight(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,1)),new ArrayList<>(Arrays.asList(1,3,3)),new ArrayList<>(Arrays.asList(1,4,5)),new ArrayList<>(Arrays.asList(2,3,2)),new ArrayList<>(Arrays.asList(4,0,1)))), 1));
27
+ }
28
+
29
+ }
minimize_the_maximum_of_two_arrays/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 (minimizeSet 2 7 1 3)," 4 (minimizeSet 2 7 1 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimizeSet 3 5 2 1)," 3 (minimizeSet 3 5 2 1))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimizeSet 2 4 8 2)," 15 (minimizeSet 2 4 8 2))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minimizeSet 4208 95692 390331116 307111670)," 697442792 (minimizeSet 4208 95692 390331116 307111670))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minimizeSet 66767 47715 109529657 689521793)," 799051450 (minimizeSet 66767 47715 109529657 689521793))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minimizeSet 66945 48742 797047732 113183367)," 910231099 (minimizeSet 66945 48742 797047732 113183367))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minimizeSet 14488 22439 373499375 218898139)," 592397515 (minimizeSet 14488 22439 373499375 218898139))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minimizeSet 54486 72001 372877909 182636630)," 555514539 (minimizeSet 54486 72001 372877909 182636630))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minimizeSet 79990 13730 621494960 204810810)," 826305777 (minimizeSet 79990 13730 621494960 204810810))
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
minimize_the_maximum_of_two_arrays/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(4, minimizeSet(2, 7, 1, 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, minimizeSet(3, 5, 2, 1));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(15, minimizeSet(2, 4, 8, 2));
23
+ }
24
+
25
+ }
minimize_the_maximum_of_two_arrays/meta.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2628,
3
+ "name": "minimize_the_maximum_of_two_arrays",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/minimize-the-maximum-of-two-arrays/",
6
+ "date": "2022-12-10 00:00:00",
7
+ "task_description": "We have two arrays `arr1` and `arr2` which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions: `arr1` contains `uniqueCnt1` **distinct** positive integers, each of which is **not divisible** by `divisor1`. `arr2` contains `uniqueCnt2` **distinct** positive integers, each of which is **not divisible** by `divisor2`. **No** integer is present in both `arr1` and `arr2`. Given `divisor1`, `divisor2`, `uniqueCnt1`, and `uniqueCnt2`, return _the **minimum possible maximum** integer that can be present in either array_. **Example 1:** ``` **Input:** divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3 **Output:** 4 **Explanation:** We can distribute the first 4 natural numbers into arr1 and arr2. arr1 = [1] and arr2 = [2,3,4]. We can see that both arrays satisfy all the conditions. Since the maximum value is 4, we return it. ``` **Example 2:** ``` **Input:** divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1 **Output:** 3 **Explanation:** Here arr1 = [1,2], and arr2 = [3] satisfy all conditions. Since the maximum value is 3, we return it. ``` **Example 3:** ``` **Input:** divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2 **Output:** 15 **Explanation:** Here, the final possible arrays can be arr1 = [1,3,5,7,9,11,13,15], and arr2 = [2,6]. It can be shown that it is not possible to obtain a lower maximum satisfying all conditions. ``` **Constraints:** `2 <= divisor1, divisor2 <= 105` `1 <= uniqueCnt1, uniqueCnt2 < 109` `2 <= uniqueCnt1 + uniqueCnt2 <= 109`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1",
17
+ "output": "3 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2",
22
+ "output": "15 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 4208,
29
+ 95692,
30
+ 390331116,
31
+ 307111670
32
+ ],
33
+ "output": 697442792
34
+ },
35
+ {
36
+ "input": [
37
+ 66767,
38
+ 47715,
39
+ 109529657,
40
+ 689521793
41
+ ],
42
+ "output": 799051450
43
+ },
44
+ {
45
+ "input": [
46
+ 66945,
47
+ 48742,
48
+ 797047732,
49
+ 113183367
50
+ ],
51
+ "output": 910231099
52
+ },
53
+ {
54
+ "input": [
55
+ 14488,
56
+ 22439,
57
+ 373499375,
58
+ 218898139
59
+ ],
60
+ "output": 592397515
61
+ },
62
+ {
63
+ "input": [
64
+ 54486,
65
+ 72001,
66
+ 372877909,
67
+ 182636630
68
+ ],
69
+ "output": 555514539
70
+ },
71
+ {
72
+ "input": [
73
+ 79990,
74
+ 13730,
75
+ 621494960,
76
+ 204810810
77
+ ],
78
+ "output": 826305777
79
+ },
80
+ {
81
+ "input": [
82
+ 66358,
83
+ 35001,
84
+ 708940014,
85
+ 188029353
86
+ ],
87
+ "output": 896969367
88
+ }
89
+ ],
90
+ "haskell_template": "minimizeSet :: Int -> Int -> Int -> Int -> Int\nminimizeSet divisor1 divisor2 uniqueCnt1 uniqueCnt2 ",
91
+ "ocaml_template": "let minimizeSet (divisor1: int) (divisor2: int) (uniqueCnt1: int) (uniqueCnt2: int) : int = ",
92
+ "scala_template": "def minimizeSet(divisor1: Int,divisor2: Int,uniqueCnt1: Int,uniqueCnt2: Int): Int = { \n \n}",
93
+ "java_template": "class Solution {\n public int minimizeSet(int divisor1, int divisor2, int uniqueCnt1, int uniqueCnt2) {\n \n }\n}",
94
+ "python_template": "class Solution(object):\n def minimizeSet(self, divisor1, divisor2, uniqueCnt1, uniqueCnt2):\n \"\"\"\n :type divisor1: int\n :type divisor2: int\n :type uniqueCnt1: int\n :type uniqueCnt2: int\n :rtype: int\n \"\"\"\n "
95
+ }
minimize_the_maximum_of_two_arrays/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 4 (minimizeSet 2 7 1 3)
12
+
13
+ let test2 _ = assert_equal 3 (minimizeSet 3 5 2 1)
14
+
15
+ let test3 _ = assert_equal 15 (minimizeSet 2 4 8 2)
16
+
17
+ let test4 _ = assert_equal 697442792 (minimizeSet 4208 95692 390331116 307111670)
18
+
19
+ let test5 _ = assert_equal 799051450 (minimizeSet 66767 47715 109529657 689521793)
20
+
21
+ let test6 _ = assert_equal 910231099 (minimizeSet 66945 48742 797047732 113183367)
22
+
23
+ let test7 _ = assert_equal 592397515 (minimizeSet 14488 22439 373499375 218898139)
24
+
25
+ let test8 _ = assert_equal 555514539 (minimizeSet 54486 72001 372877909 182636630)
26
+
27
+ let test9 _ = assert_equal 826305777 (minimizeSet 79990 13730 621494960 204810810)
28
+
29
+ let test10 _ = assert_equal 896969367 (minimizeSet 66358 35001 708940014 188029353)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minimizeSet" >::: [
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