DatasetRepo commited on
Commit
e77522d
·
verified ·
1 Parent(s): 6e4e317

c75bb478d76edd30f548673176503faeda3793d5a03e5a4667861245429d1b72

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. minimum_number_of_operations_to_make_array_empty/ocaml_tests/main.ml +0 -0
  3. minimum_number_of_operations_to_make_array_empty/scala_tests/MySuite.scala +0 -0
  4. minimum_number_of_operations_to_make_array_xor_equal_to_k/haskell_tests/Main.hs +0 -0
  5. minimum_number_of_operations_to_make_array_xor_equal_to_k/java_tests/Main.java +21 -0
  6. minimum_number_of_operations_to_make_array_xor_equal_to_k/meta.json +3 -0
  7. minimum_number_of_operations_to_make_array_xor_equal_to_k/ocaml_tests/main.ml +0 -0
  8. minimum_number_of_operations_to_make_array_xor_equal_to_k/scala_tests/MySuite.scala +0 -0
  9. minimum_number_of_operations_to_make_arrays_similar/.DS_Store +0 -0
  10. minimum_number_of_operations_to_make_arrays_similar/haskell_tests/Main.hs +27 -0
  11. minimum_number_of_operations_to_make_arrays_similar/java_tests/Main.java +25 -0
  12. minimum_number_of_operations_to_make_arrays_similar/meta.json +3 -0
  13. minimum_number_of_operations_to_make_arrays_similar/ocaml_tests/main.ml +29 -0
  14. minimum_number_of_operations_to_make_arrays_similar/scala_tests/MySuite.scala +16 -0
  15. minimum_number_of_operations_to_make_elements_in_array_distinct/haskell_tests/Main.hs +44 -0
  16. minimum_number_of_operations_to_make_elements_in_array_distinct/java_tests/Main.java +24 -0
  17. minimum_number_of_operations_to_make_elements_in_array_distinct/meta.json +348 -0
  18. minimum_number_of_operations_to_make_elements_in_array_distinct/ocaml_tests/main.ml +45 -0
  19. minimum_number_of_operations_to_make_elements_in_array_distinct/scala_tests/MySuite.scala +36 -0
  20. minimum_number_of_operations_to_make_word_k_periodic/haskell_tests/Main.hs +0 -0
  21. minimum_number_of_operations_to_make_word_k_periodic/java_tests/Main.java +21 -0
  22. minimum_number_of_operations_to_make_word_k_periodic/meta.json +0 -0
  23. minimum_number_of_operations_to_make_word_k_periodic/ocaml_tests/main.ml +0 -0
  24. minimum_number_of_operations_to_make_word_k_periodic/scala_tests/MySuite.scala +0 -0
  25. minimum_number_of_operations_to_make_x_and_y_equal/haskell_tests/Main.hs +45 -0
  26. minimum_number_of_operations_to_make_x_and_y_equal/java_tests/Main.java +25 -0
  27. minimum_number_of_operations_to_make_x_and_y_equal/meta.json +102 -0
  28. minimum_number_of_operations_to_make_x_and_y_equal/ocaml_tests/main.ml +50 -0
  29. minimum_number_of_operations_to_make_x_and_y_equal/scala_tests/MySuite.scala +44 -0
  30. minimum_number_of_operations_to_satisfy_conditions/haskell_tests/Main.hs +0 -0
  31. minimum_number_of_operations_to_satisfy_conditions/java_tests/Main.java +24 -0
  32. minimum_number_of_operations_to_satisfy_conditions/meta.json +3 -0
  33. minimum_number_of_operations_to_satisfy_conditions/ocaml_tests/main.ml +0 -0
  34. minimum_number_of_operations_to_satisfy_conditions/scala_tests/MySuite.scala +0 -0
  35. minimum_number_of_pushes_to_type_word_i/haskell_tests/Main.hs +47 -0
  36. minimum_number_of_pushes_to_type_word_i/java_tests/Main.java +20 -0
  37. minimum_number_of_pushes_to_type_word_i/meta.json +67 -0
  38. minimum_number_of_pushes_to_type_word_i/ocaml_tests/main.ml +51 -0
  39. minimum_number_of_pushes_to_type_word_i/scala_tests/MySuite.scala +44 -0
  40. minimum_number_of_pushes_to_type_word_ii/haskell_tests/Main.hs +0 -0
  41. minimum_number_of_pushes_to_type_word_ii/java_tests/Main.java +24 -0
  42. minimum_number_of_pushes_to_type_word_ii/meta.json +0 -0
  43. minimum_number_of_pushes_to_type_word_ii/ocaml_tests/main.ml +0 -0
  44. minimum_number_of_pushes_to_type_word_ii/scala_tests/MySuite.scala +0 -0
  45. minimum_number_of_seconds_to_make_mountain_height_zero/haskell_tests/Main.hs +0 -0
  46. minimum_number_of_seconds_to_make_mountain_height_zero/java_tests/Main.java +25 -0
  47. minimum_number_of_seconds_to_make_mountain_height_zero/meta.json +0 -0
  48. minimum_number_of_seconds_to_make_mountain_height_zero/ocaml_tests/main.ml +0 -0
  49. minimum_number_of_seconds_to_make_mountain_height_zero/scala_tests/MySuite.scala +0 -0
  50. minimum_number_of_steps_to_make_two_strings_anagram_ii/.DS_Store +0 -0
.gitattributes CHANGED
@@ -221,3 +221,6 @@ minimum_impossible_or/meta.json filter=lfs diff=lfs merge=lfs -text
221
  minimum_lines_to_represent_a_line_chart/meta.json filter=lfs diff=lfs merge=lfs -text
222
  minimum_money_required_before_transactions/meta.json filter=lfs diff=lfs merge=lfs -text
223
  minimum_number_of_coins_to_be_added/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
221
  minimum_lines_to_represent_a_line_chart/meta.json filter=lfs diff=lfs merge=lfs -text
222
  minimum_money_required_before_transactions/meta.json filter=lfs diff=lfs merge=lfs -text
223
  minimum_number_of_coins_to_be_added/meta.json filter=lfs diff=lfs merge=lfs -text
224
+ minimum_number_of_operations_to_make_array_xor_equal_to_k/meta.json filter=lfs diff=lfs merge=lfs -text
225
+ minimum_number_of_operations_to_make_arrays_similar/meta.json filter=lfs diff=lfs merge=lfs -text
226
+ minimum_number_of_operations_to_satisfy_conditions/meta.json filter=lfs diff=lfs merge=lfs -text
minimum_number_of_operations_to_make_array_empty/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_array_empty/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_array_xor_equal_to_k/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_array_xor_equal_to_k/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, minOperations(new ArrayList<>(Arrays.asList(2,1,3,4)), 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, minOperations(new ArrayList<>(Arrays.asList(2,0,2,0)), 0));
19
+ }
20
+
21
+ }
minimum_number_of_operations_to_make_array_xor_equal_to_k/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a09fbafdd994ed0246fac537f5c619c30e9e1a51f87c362a80209c8bcb6172d2
3
+ size 18682869
minimum_number_of_operations_to_make_array_xor_equal_to_k/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_array_xor_equal_to_k/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_arrays_similar/.DS_Store ADDED
Binary file (6.15 kB). View file
 
minimum_number_of_operations_to_make_arrays_similar/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 (makeSimilar [8,12,6] [2,14,10])," 2 (makeSimilar [8,12,6] [2,14,10]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (makeSimilar [1,2,5] [4,1,3])," 1 (makeSimilar [1,2,5] [4,1,3]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (makeSimilar [1,1,1,1,1] [1,1,1,1,1])," 0 (makeSimilar [1,1,1,1,1] [1,1,1,1,1]))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
minimum_number_of_operations_to_make_arrays_similar/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(2, makeSimilar(new ArrayList<>(Arrays.asList(8,12,6)), new ArrayList<>(Arrays.asList(2,14,10))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, makeSimilar(new ArrayList<>(Arrays.asList(1,2,5)), new ArrayList<>(Arrays.asList(4,1,3))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, makeSimilar(new ArrayList<>(Arrays.asList(1,1,1,1,1)), new ArrayList<>(Arrays.asList(1,1,1,1,1))));
23
+ }
24
+
25
+ }
minimum_number_of_operations_to_make_arrays_similar/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c46a00b856a86794e8be3df99b0fc948beb16f53a0320e1d866262c547a6d97
3
+ size 38393789
minimum_number_of_operations_to_make_arrays_similar/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 (makeSimilar [8;12;6] [2;14;10])
12
+
13
+ let test2 _ = assert_equal 1 (makeSimilar [1;2;5] [4;1;3])
14
+
15
+ let test3 _ = assert_equal 0 (makeSimilar [1;1;1;1;1] [1;1;1;1;1])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for makeSimilar" >::: [
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_number_of_operations_to_make_arrays_similar/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.makeSimilar(List(8,12,6),List(2,14,10)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.makeSimilar(List(1,2,5),List(4,1,3)), 1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.makeSimilar(List(1,1,1,1,1),List(1,1,1,1,1)), 0)
14
+ }
15
+
16
+ }
minimum_number_of_operations_to_make_elements_in_array_distinct/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimumOperations :: [Int] -> Int
7
+ minimumOperations nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimumOperations [1,2,3,4,2,3,3,5,7])," 2 (minimumOperations [1,2,3,4,2,3,3,5,7]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimumOperations [4,5,6,4,4])," 2 (minimumOperations [4,5,6,4,4]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimumOperations [6,7,8,9])," 0 (minimumOperations [6,7,8,9]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimumOperations [67, 17, 59, 80, 12, 32, 84, 64, 51, 82, 92, 54, 36, 31, 42, 21, 24, 85, 18, 47, 78, 74, 81, 76, 61, 22, 69, 88, 37, 73, 3, 23, 63, 18, 69, 7, 81, 4, 92, 90, 33, 65, 94, 79, 53, 91, 37, 36, 72, 91, 18, 97, 5, 63, 62, 41, 29, 56, 20, 24, 28, 42, 43, 96, 67, 42, 62, 75, 43, 75, 52, 90, 67, 83, 22, 38, 44])," 23 (minimumOperations [67, 17, 59, 80, 12, 32, 84, 64, 51, 82, 92, 54, 36, 31, 42, 21, 24, 85, 18, 47, 78, 74, 81, 76, 61, 22, 69, 88, 37, 73, 3, 23, 63, 18, 69, 7, 81, 4, 92, 90, 33, 65, 94, 79, 53, 91, 37, 36, 72, 91, 18, 97, 5, 63, 62, 41, 29, 56, 20, 24, 28, 42, 43, 96, 67, 42, 62, 75, 43, 75, 52, 90, 67, 83, 22, 38, 44]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimumOperations [91, 70, 32, 38, 40, 94, 88, 3, 82, 54, 28, 15, 85, 21, 82, 17, 25, 26, 13, 52, 69, 79, 70, 89, 12, 91, 71, 96, 55, 5, 17, 86, 97, 71, 68, 29, 57, 11, 35, 25, 41])," 9 (minimumOperations [91, 70, 32, 38, 40, 94, 88, 3, 82, 54, 28, 15, 85, 21, 82, 17, 25, 26, 13, 52, 69, 79, 70, 89, 12, 91, 71, 96, 55, 5, 17, 86, 97, 71, 68, 29, 57, 11, 35, 25, 41]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimumOperations [91, 66, 77, 90, 9, 73, 55, 35, 25, 55, 65, 97, 86, 8, 42, 75, 59, 10, 25, 9, 70, 80, 1, 47, 56, 53, 25, 93, 69, 18, 30])," 7 (minimumOperations [91, 66, 77, 90, 9, 73, 55, 35, 25, 55, 65, 97, 86, 8, 42, 75, 59, 10, 25, 9, 70, 80, 1, 47, 56, 53, 25, 93, 69, 18, 30]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimumOperations [16, 74, 63, 68, 63, 15, 89, 71, 24, 100, 41, 95, 28, 83, 36, 42, 46, 40, 70, 93, 10, 98, 35, 93, 70, 8, 36, 72, 40, 31, 61, 91, 16, 42, 42, 59, 20, 67, 28, 85, 29, 22, 54, 86, 49, 4, 3, 86, 42, 44, 100, 9, 26, 41, 36, 5, 19, 46, 8, 59, 63, 73, 34, 83, 4, 21, 50, 78, 25, 42, 25, 9, 53, 62, 66, 62, 32, 100, 2])," 25 (minimumOperations [16, 74, 63, 68, 63, 15, 89, 71, 24, 100, 41, 95, 28, 83, 36, 42, 46, 40, 70, 93, 10, 98, 35, 93, 70, 8, 36, 72, 40, 31, 61, 91, 16, 42, 42, 59, 20, 67, 28, 85, 29, 22, 54, 86, 49, 4, 3, 86, 42, 44, 100, 9, 26, 41, 36, 5, 19, 46, 8, 59, 63, 73, 34, 83, 4, 21, 50, 78, 25, 42, 25, 9, 53, 62, 66, 62, 32, 100, 2]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (minimumOperations [49, 18, 41, 58, 21, 52, 12, 14, 30, 18, 68, 92, 38, 20, 73, 78, 8, 28, 43, 46, 29, 88, 48, 65, 56, 1, 52, 62, 66, 16, 94, 15, 79, 57, 50, 59, 69, 64, 22, 25, 71, 51, 39, 6, 11, 90, 4, 29, 74, 11, 29, 75, 23, 6, 51, 12, 45, 27, 33, 17, 16, 50, 60])," 16 (minimumOperations [49, 18, 41, 58, 21, 52, 12, 14, 30, 18, 68, 92, 38, 20, 73, 78, 8, 28, 43, 46, 29, 88, 48, 65, 56, 1, 52, 62, 66, 16, 94, 15, 79, 57, 50, 59, 69, 64, 22, 25, 71, 51, 39, 6, 11, 90, 4, 29, 74, 11, 29, 75, 23, 6, 51, 12, 45, 27, 33, 17, 16, 50, 60]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
minimum_number_of_operations_to_make_elements_in_array_distinct/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(2, minimumOperations(Arrays.asList(1,2,3,4,2,3,3,5,7)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(2, minimumOperations(Arrays.asList(4,5,6,4,4)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(0, minimumOperations(Arrays.asList(6,7,8,9)));
22
+ }
23
+
24
+ }
minimum_number_of_operations_to_make_elements_in_array_distinct/meta.json ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3656,
3
+ "name": "minimum_number_of_operations_to_make_elements_in_array_distinct",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/",
6
+ "date": "2024-12-15 00:00:00",
7
+ "task_description": "You are given an integer array `nums`. You need to ensure that the elements in the array are **distinct**. To achieve this, you can perform the following operation any number of times: Remove 3 elements from the beginning of the array. If the array has fewer than 3 elements, remove all remaining elements. **Note** that an empty array is considered to have distinct elements. Return the **minimum** number of operations needed to make the elements in the array distinct. **Example 1:** **Input:** nums = [1,2,3,4,2,3,3,5,7] **Output:** 2 **Explanation:** In the first operation, the first 3 elements are removed, resulting in the array `[4, 2, 3, 3, 5, 7]`. In the second operation, the next 3 elements are removed, resulting in the array `[3, 5, 7]`, which has distinct elements. Therefore, the answer is 2. **Example 2:** **Input:** nums = [4,5,6,4,4] **Output:** 2 **Explanation:** In the first operation, the first 3 elements are removed, resulting in the array `[4, 4]`. In the second operation, all remaining elements are removed, resulting in an empty array. Therefore, the answer is 2. **Example 3:** **Input:** nums = [6,7,8,9] **Output:** 0 **Explanation:** The array already contains distinct elements. Therefore, the answer is 0. **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,3,4,2,3,3,5,7]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [4,5,6,4,4]",
17
+ "output": "2 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [6,7,8,9]",
22
+ "output": "0 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 67,
29
+ 17,
30
+ 59,
31
+ 80,
32
+ 12,
33
+ 32,
34
+ 84,
35
+ 64,
36
+ 51,
37
+ 82,
38
+ 92,
39
+ 54,
40
+ 36,
41
+ 31,
42
+ 42,
43
+ 21,
44
+ 24,
45
+ 85,
46
+ 18,
47
+ 47,
48
+ 78,
49
+ 74,
50
+ 81,
51
+ 76,
52
+ 61,
53
+ 22,
54
+ 69,
55
+ 88,
56
+ 37,
57
+ 73,
58
+ 3,
59
+ 23,
60
+ 63,
61
+ 18,
62
+ 69,
63
+ 7,
64
+ 81,
65
+ 4,
66
+ 92,
67
+ 90,
68
+ 33,
69
+ 65,
70
+ 94,
71
+ 79,
72
+ 53,
73
+ 91,
74
+ 37,
75
+ 36,
76
+ 72,
77
+ 91,
78
+ 18,
79
+ 97,
80
+ 5,
81
+ 63,
82
+ 62,
83
+ 41,
84
+ 29,
85
+ 56,
86
+ 20,
87
+ 24,
88
+ 28,
89
+ 42,
90
+ 43,
91
+ 96,
92
+ 67,
93
+ 42,
94
+ 62,
95
+ 75,
96
+ 43,
97
+ 75,
98
+ 52,
99
+ 90,
100
+ 67,
101
+ 83,
102
+ 22,
103
+ 38,
104
+ 44
105
+ ],
106
+ "output": 23
107
+ },
108
+ {
109
+ "input": [
110
+ 91,
111
+ 70,
112
+ 32,
113
+ 38,
114
+ 40,
115
+ 94,
116
+ 88,
117
+ 3,
118
+ 82,
119
+ 54,
120
+ 28,
121
+ 15,
122
+ 85,
123
+ 21,
124
+ 82,
125
+ 17,
126
+ 25,
127
+ 26,
128
+ 13,
129
+ 52,
130
+ 69,
131
+ 79,
132
+ 70,
133
+ 89,
134
+ 12,
135
+ 91,
136
+ 71,
137
+ 96,
138
+ 55,
139
+ 5,
140
+ 17,
141
+ 86,
142
+ 97,
143
+ 71,
144
+ 68,
145
+ 29,
146
+ 57,
147
+ 11,
148
+ 35,
149
+ 25,
150
+ 41
151
+ ],
152
+ "output": 9
153
+ },
154
+ {
155
+ "input": [
156
+ 91,
157
+ 66,
158
+ 77,
159
+ 90,
160
+ 9,
161
+ 73,
162
+ 55,
163
+ 35,
164
+ 25,
165
+ 55,
166
+ 65,
167
+ 97,
168
+ 86,
169
+ 8,
170
+ 42,
171
+ 75,
172
+ 59,
173
+ 10,
174
+ 25,
175
+ 9,
176
+ 70,
177
+ 80,
178
+ 1,
179
+ 47,
180
+ 56,
181
+ 53,
182
+ 25,
183
+ 93,
184
+ 69,
185
+ 18,
186
+ 30
187
+ ],
188
+ "output": 7
189
+ },
190
+ {
191
+ "input": [
192
+ 16,
193
+ 74,
194
+ 63,
195
+ 68,
196
+ 63,
197
+ 15,
198
+ 89,
199
+ 71,
200
+ 24,
201
+ 100,
202
+ 41,
203
+ 95,
204
+ 28,
205
+ 83,
206
+ 36,
207
+ 42,
208
+ 46,
209
+ 40,
210
+ 70,
211
+ 93,
212
+ 10,
213
+ 98,
214
+ 35,
215
+ 93,
216
+ 70,
217
+ 8,
218
+ 36,
219
+ 72,
220
+ 40,
221
+ 31,
222
+ 61,
223
+ 91,
224
+ 16,
225
+ 42,
226
+ 42,
227
+ 59,
228
+ 20,
229
+ 67,
230
+ 28,
231
+ 85,
232
+ 29,
233
+ 22,
234
+ 54,
235
+ 86,
236
+ 49,
237
+ 4,
238
+ 3,
239
+ 86,
240
+ 42,
241
+ 44,
242
+ 100,
243
+ 9,
244
+ 26,
245
+ 41,
246
+ 36,
247
+ 5,
248
+ 19,
249
+ 46,
250
+ 8,
251
+ 59,
252
+ 63,
253
+ 73,
254
+ 34,
255
+ 83,
256
+ 4,
257
+ 21,
258
+ 50,
259
+ 78,
260
+ 25,
261
+ 42,
262
+ 25,
263
+ 9,
264
+ 53,
265
+ 62,
266
+ 66,
267
+ 62,
268
+ 32,
269
+ 100,
270
+ 2
271
+ ],
272
+ "output": 25
273
+ },
274
+ {
275
+ "input": [
276
+ 49,
277
+ 18,
278
+ 41,
279
+ 58,
280
+ 21,
281
+ 52,
282
+ 12,
283
+ 14,
284
+ 30,
285
+ 18,
286
+ 68,
287
+ 92,
288
+ 38,
289
+ 20,
290
+ 73,
291
+ 78,
292
+ 8,
293
+ 28,
294
+ 43,
295
+ 46,
296
+ 29,
297
+ 88,
298
+ 48,
299
+ 65,
300
+ 56,
301
+ 1,
302
+ 52,
303
+ 62,
304
+ 66,
305
+ 16,
306
+ 94,
307
+ 15,
308
+ 79,
309
+ 57,
310
+ 50,
311
+ 59,
312
+ 69,
313
+ 64,
314
+ 22,
315
+ 25,
316
+ 71,
317
+ 51,
318
+ 39,
319
+ 6,
320
+ 11,
321
+ 90,
322
+ 4,
323
+ 29,
324
+ 74,
325
+ 11,
326
+ 29,
327
+ 75,
328
+ 23,
329
+ 6,
330
+ 51,
331
+ 12,
332
+ 45,
333
+ 27,
334
+ 33,
335
+ 17,
336
+ 16,
337
+ 50,
338
+ 60
339
+ ],
340
+ "output": 16
341
+ }
342
+ ],
343
+ "haskell_template": "minimumOperations :: [Int] -> Int\nminimumOperations nums ",
344
+ "ocaml_template": "let minimumOperations (nums: int list) : int = ",
345
+ "scala_template": "def minimumOperations(nums: List[Int]): Int = { \n \n}",
346
+ "java_template": "class Solution {\n public int minimumOperations(int[] nums) {\n \n }\n}",
347
+ "python_template": "class Solution(object):\n def minimumOperations(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
348
+ }
minimum_number_of_operations_to_make_elements_in_array_distinct/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimumOperations (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 2 (minimumOperations [1;2;3;4;2;3;3;5;7])
13
+
14
+ let test2 _ = assert_equal 2 (minimumOperations [4;5;6;4;4])
15
+
16
+ let test3 _ = assert_equal 0 (minimumOperations [6;7;8;9])
17
+
18
+ let test4 _ = assert_equal 0 (minimumOperations [67; 17; 59; 80; 12; 32; 84; 64; 51; 82; 92; 54; 36; 31; 42; 21; 24; 85; 18; 47; 78; 74; 81; 76; 61; 22; 69; 88; 37; 73; 3; 23; 63; 18; 69; 7; 81; 4; 92; 90; 33; 65; 94; 79; 53; 91; 37; 36; 72; 91; 18; 97; 5; 63; 62; 41; 29; 56; 20; 24; 28; 42; 43; 96; 67; 42; 62; 75; 43; 75; 52; 90; 67; 83; 22; 38; 44])
19
+
20
+ let test5 _ = assert_equal 0 (minimumOperations [91; 70; 32; 38; 40; 94; 88; 3; 82; 54; 28; 15; 85; 21; 82; 17; 25; 26; 13; 52; 69; 79; 70; 89; 12; 91; 71; 96; 55; 5; 17; 86; 97; 71; 68; 29; 57; 11; 35; 25; 41])
21
+
22
+ let test6 _ = assert_equal 0 (minimumOperations [91; 66; 77; 90; 9; 73; 55; 35; 25; 55; 65; 97; 86; 8; 42; 75; 59; 10; 25; 9; 70; 80; 1; 47; 56; 53; 25; 93; 69; 18; 30])
23
+
24
+ let test7 _ = assert_equal 0 (minimumOperations [16; 74; 63; 68; 63; 15; 89; 71; 24; 100; 41; 95; 28; 83; 36; 42; 46; 40; 70; 93; 10; 98; 35; 93; 70; 8; 36; 72; 40; 31; 61; 91; 16; 42; 42; 59; 20; 67; 28; 85; 29; 22; 54; 86; 49; 4; 3; 86; 42; 44; 100; 9; 26; 41; 36; 5; 19; 46; 8; 59; 63; 73; 34; 83; 4; 21; 50; 78; 25; 42; 25; 9; 53; 62; 66; 62; 32; 100; 2])
25
+
26
+ let test8 _ = assert_equal 0 (minimumOperations [49; 18; 41; 58; 21; 52; 12; 14; 30; 18; 68; 92; 38; 20; 73; 78; 8; 28; 43; 46; 29; 88; 48; 65; 56; 1; 52; 62; 66; 16; 94; 15; 79; 57; 50; 59; 69; 64; 22; 25; 71; 51; 39; 6; 11; 90; 4; 29; 74; 11; 29; 75; 23; 6; 51; 12; 45; 27; 33; 17; 16; 50; 60])
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for minimumOperations" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end
minimum_number_of_operations_to_make_elements_in_array_distinct/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumOperations(List(1,2,3,4,2,3,3,5,7)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumOperations(List(4,5,6,4,4)), 2)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumOperations(List(6,7,8,9)), 0)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumOperations(67,17,59,80,12,32,84,64,51,82,92,54,36,31,42,21,24,85,18,47,78,74,81,76,61,22,69,88,37,73,3,23,63,18,69,7,81,4,92,90,33,65,94,79,53,91,37,36,72,91,18,97,5,63,62,41,29,56,20,24,28,42,43,96,67,42,62,75,43,75,52,90,67,83,22,38,44), 23)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumOperations(91,70,32,38,40,94,88,3,82,54,28,15,85,21,82,17,25,26,13,52,69,79,70,89,12,91,71,96,55,5,17,86,97,71,68,29,57,11,35,25,41), 9)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumOperations(91,66,77,90,9,73,55,35,25,55,65,97,86,8,42,75,59,10,25,9,70,80,1,47,56,53,25,93,69,18,30), 7)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumOperations(16,74,63,68,63,15,89,71,24,100,41,95,28,83,36,42,46,40,70,93,10,98,35,93,70,8,36,72,40,31,61,91,16,42,42,59,20,67,28,85,29,22,54,86,49,4,3,86,42,44,100,9,26,41,36,5,19,46,8,59,63,73,34,83,4,21,50,78,25,42,25,9,53,62,66,62,32,100,2), 25)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumOperations(49,18,41,58,21,52,12,14,30,18,68,92,38,20,73,78,8,28,43,46,29,88,48,65,56,1,52,62,66,16,94,15,79,57,50,59,69,64,22,25,71,51,39,6,11,90,4,29,74,11,29,75,23,6,51,12,45,27,33,17,16,50,60), 16)
34
+ }
35
+
36
+ }
minimum_number_of_operations_to_make_word_k_periodic/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_word_k_periodic/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, minimumOperationsToMakeKPeriodic("leetcodeleet", 4));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, minimumOperationsToMakeKPeriodic(" leetcoleet ", 2));
19
+ }
20
+
21
+ }
minimum_number_of_operations_to_make_word_k_periodic/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_word_k_periodic/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_word_k_periodic/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_make_x_and_y_equal/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 (minimumOperationsToMakeEqual 26 1)," 3 (minimumOperationsToMakeEqual 26 1))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 54 2)," 4 (minimumOperationsToMakeEqual 54 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 25 30)," 5 (minimumOperationsToMakeEqual 25 30))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 6266 3684)," 2433 (minimumOperationsToMakeEqual 6266 3684))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 2531 2524)," 7 (minimumOperationsToMakeEqual 2531 2524))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 6102 3286)," 2069 (minimumOperationsToMakeEqual 6102 3286))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 5781 8456)," 2675 (minimumOperationsToMakeEqual 5781 8456))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 8010 279)," 45 (minimumOperationsToMakeEqual 8010 279))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (minimumOperationsToMakeEqual 7279 648)," 18 (minimumOperationsToMakeEqual 7279 648))
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_number_of_operations_to_make_x_and_y_equal/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, minimumOperationsToMakeEqual(26, 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, minimumOperationsToMakeEqual(54, 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(5, minimumOperationsToMakeEqual(25, 30));
23
+ }
24
+
25
+ }
minimum_number_of_operations_to_make_x_and_y_equal/meta.json ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3239,
3
+ "name": "minimum_number_of_operations_to_make_x_and_y_equal",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-x-and-y-equal/",
6
+ "date": "2023-12-23 00:00:00",
7
+ "task_description": "You are given two positive integers `x` and `y`. In one operation, you can do one of the four following operations: Divide `x` by `11` if `x` is a multiple of `11`. Divide `x` by `5` if `x` is a multiple of `5`. Decrement `x` by `1`. Increment `x` by `1`. Return _the **minimum** number of operations required to make _ `x` and `y` equal. **Example 1:** ``` **Input:** x = 26, y = 1 **Output:** 3 **Explanation:** We can make 26 equal to 1 by applying the following operations: 1. Decrement x by 1 2. Divide x by 5 3. Divide x by 5 It can be shown that 3 is the minimum number of operations required to make 26 equal to 1. ``` **Example 2:** ``` **Input:** x = 54, y = 2 **Output:** 4 **Explanation:** We can make 54 equal to 2 by applying the following operations: 1. Increment x by 1 2. Divide x by 11 3. Divide x by 5 4. Increment x by 1 It can be shown that 4 is the minimum number of operations required to make 54 equal to 2. ``` **Example 3:** ``` **Input:** x = 25, y = 30 **Output:** 5 **Explanation:** We can make 25 equal to 30 by applying the following operations: 1. Increment x by 1 2. Increment x by 1 3. Increment x by 1 4. Increment x by 1 5. Increment x by 1 It can be shown that 5 is the minimum number of operations required to make 25 equal to 30. ``` **Constraints:** `1 <= x, y <= 104`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "x = 26, y = 1",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "x = 54, y = 2",
17
+ "output": "4 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "x = 25, y = 30",
22
+ "output": "5 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 6266,
29
+ 3684
30
+ ],
31
+ "output": 2433
32
+ },
33
+ {
34
+ "input": [
35
+ 2531,
36
+ 2524
37
+ ],
38
+ "output": 7
39
+ },
40
+ {
41
+ "input": [
42
+ 6102,
43
+ 3286
44
+ ],
45
+ "output": 2069
46
+ },
47
+ {
48
+ "input": [
49
+ 5781,
50
+ 8456
51
+ ],
52
+ "output": 2675
53
+ },
54
+ {
55
+ "input": [
56
+ 8010,
57
+ 279
58
+ ],
59
+ "output": 45
60
+ },
61
+ {
62
+ "input": [
63
+ 7279,
64
+ 648
65
+ ],
66
+ "output": 18
67
+ },
68
+ {
69
+ "input": [
70
+ 4579,
71
+ 2883
72
+ ],
73
+ "output": 1696
74
+ },
75
+ {
76
+ "input": [
77
+ 8696,
78
+ 4573
79
+ ],
80
+ "output": 2836
81
+ },
82
+ {
83
+ "input": [
84
+ 8343,
85
+ 7156
86
+ ],
87
+ "output": 1187
88
+ },
89
+ {
90
+ "input": [
91
+ 4572,
92
+ 8515
93
+ ],
94
+ "output": 3943
95
+ }
96
+ ],
97
+ "haskell_template": "minimumOperationsToMakeEqual :: Int -> Int -> Int\nminimumOperationsToMakeEqual x y ",
98
+ "ocaml_template": "let minimumOperationsToMakeEqual (x: int) (y: int) : int = ",
99
+ "scala_template": "def minimumOperationsToMakeEqual(x: Int,y: Int): Int = { \n \n}",
100
+ "java_template": "class Solution {\n public int minimumOperationsToMakeEqual(int x, int y) {\n \n }\n}",
101
+ "python_template": "class Solution(object):\n def minimumOperationsToMakeEqual(self, x, y):\n \"\"\"\n :type x: int\n :type y: int\n :rtype: int\n \"\"\"\n "
102
+ }
minimum_number_of_operations_to_make_x_and_y_equal/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (minimumOperationsToMakeEqual 26 1)
12
+
13
+ let test2 _ = assert_equal 4 (minimumOperationsToMakeEqual 54 2)
14
+
15
+ let test3 _ = assert_equal 5 (minimumOperationsToMakeEqual 25 30)
16
+
17
+ let test4 _ = assert_equal 2433 (minimumOperationsToMakeEqual 6266 3684)
18
+
19
+ let test5 _ = assert_equal 7 (minimumOperationsToMakeEqual 2531 2524)
20
+
21
+ let test6 _ = assert_equal 2069 (minimumOperationsToMakeEqual 6102 3286)
22
+
23
+ let test7 _ = assert_equal 2675 (minimumOperationsToMakeEqual 5781 8456)
24
+
25
+ let test8 _ = assert_equal 45 (minimumOperationsToMakeEqual 8010 279)
26
+
27
+ let test9 _ = assert_equal 18 (minimumOperationsToMakeEqual 7279 648)
28
+
29
+ let test10 _ = assert_equal 1696 (minimumOperationsToMakeEqual 4579 2883)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for minimumOperationsToMakeEqual" >::: [
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_number_of_operations_to_make_x_and_y_equal/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumOperationsToMakeEqual(26,1), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumOperationsToMakeEqual(54,2), 4)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumOperationsToMakeEqual(25,30), 5)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumOperationsToMakeEqual(6266,3684), 2433)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumOperationsToMakeEqual(2531,2524), 7)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumOperationsToMakeEqual(6102,3286), 2069)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumOperationsToMakeEqual(5781,8456), 2675)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumOperationsToMakeEqual(8010,279), 45)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumOperationsToMakeEqual(7279,648), 18)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumOperationsToMakeEqual(4579,2883), 1696)
42
+ }
43
+
44
+ }
minimum_number_of_operations_to_satisfy_conditions/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_satisfy_conditions/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(0, minimumOperations(Arrays.asList(Arrays.asList(1,0,2),Arrays.asList(1,0,2))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(3, minimumOperations(Arrays.asList(Arrays.asList(1,1,1),Arrays.asList(0,0,0))));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(2, minimumOperations(Arrays.asList(Arrays.asList(1),Arrays.asList(2),Arrays.asList(3))));
22
+ }
23
+
24
+ }
minimum_number_of_operations_to_satisfy_conditions/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6e38307746976dee3b8ccd348936874d32150aeef318d6546ddfb6cd1e7e897
3
+ size 22889609
minimum_number_of_operations_to_satisfy_conditions/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_operations_to_satisfy_conditions/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_pushes_to_type_word_i/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ minimumPushes :: String -> Int
7
+ minimumPushes word = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (minimumPushes \"abcde \")," 5 (minimumPushes "abcde"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (minimumPushes \"xycdefghij \")," 12 (minimumPushes "xycdefghij"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (minimumPushes \"ytpmlveqaorscn \")," 20 (minimumPushes "ytpmlveqaorscn"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (minimumPushes \"oabctkjnyrqlvsfmgwux \")," 36 (minimumPushes "oabctkjnyrqlvsfmgwux"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (minimumPushes \"fzrqwode \")," 8 (minimumPushes "fzrqwode"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (minimumPushes \"gcnmiyrdhzvk \")," 16 (minimumPushes "gcnmiyrdhzvk"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (minimumPushes \"kpsahebnwdo \")," 14 (minimumPushes "kpsahebnwdo"))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (minimumPushes \"suvwdacbqxpkrgiyftl \")," 33 (minimumPushes "suvwdacbqxpkrgiyftl"))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (minimumPushes \"kefduqyzhgsxialp \")," 24 (minimumPushes "kefduqyzhgsxialp"))
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_number_of_pushes_to_type_word_i/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(5, minimumPushes("abcde"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(12, minimumPushes("xycdefghij"));
18
+ }
19
+
20
+ }
minimum_number_of_pushes_to_type_word_i/meta.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3275,
3
+ "name": "minimum_number_of_pushes_to_type_word_i",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i/",
6
+ "date": "2024-01-14 00:00:00",
7
+ "task_description": "You are given a string `word` containing **distinct** lowercase English letters. Telephone keypads have keys mapped with **distinct** collections of lowercase English letters, which can be used to form words by pushing them. For example, the key `2` is mapped with `[\"a\",\"b\",\"c\"]`, we need to push the key one time to type `\"a\"`, two times to type `\"b\"`, and three times to type `\"c\"` _._ It is allowed to remap the keys numbered `2` to `9` to **distinct** collections of letters. The keys can be remapped to **any** amount of letters, but each letter **must** be mapped to **exactly** one key. You need to find the **minimum** number of times the keys will be pushed to type the string `word`. Return _the **minimum** number of pushes needed to type _`word` _after remapping the keys_. An example mapping of letters to keys on a telephone keypad is given below. Note that `1`, `*`, `#`, and `0` do **not** map to any letters. **Example 1:** ``` **Input:** word = \"abcde\" **Output:** 5 **Explanation:** The remapped keypad given in the image provides the minimum cost. \"a\" -> one push on key 2 \"b\" -> one push on key 3 \"c\" -> one push on key 4 \"d\" -> one push on key 5 \"e\" -> one push on key 6 Total cost is 1 + 1 + 1 + 1 + 1 = 5. It can be shown that no other mapping can provide a lower cost. ``` **Example 2:** ``` **Input:** word = \"xycdefghij\" **Output:** 12 **Explanation:** The remapped keypad given in the image provides the minimum cost. \"x\" -> one push on key 2 \"y\" -> two pushes on key 2 \"c\" -> one push on key 3 \"d\" -> two pushes on key 3 \"e\" -> one push on key 4 \"f\" -> one push on key 5 \"g\" -> one push on key 6 \"h\" -> one push on key 7 \"i\" -> one push on key 8 \"j\" -> one push on key 9 Total cost is 1 + 2 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 = 12. It can be shown that no other mapping can provide a lower cost. ``` **Constraints:** `1 <= word.length <= 26` `word` consists of lowercase English letters. All letters in `word` are distinct.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "word = \"abcde\"",
12
+ "output": "5 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "word = \"xycdefghij\"",
17
+ "output": "12 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "ytpmlveqaorscn",
23
+ "output": 20
24
+ },
25
+ {
26
+ "input": "oabctkjnyrqlvsfmgwux",
27
+ "output": 36
28
+ },
29
+ {
30
+ "input": "fzrqwode",
31
+ "output": 8
32
+ },
33
+ {
34
+ "input": "gcnmiyrdhzvk",
35
+ "output": 16
36
+ },
37
+ {
38
+ "input": "kpsahebnwdo",
39
+ "output": 14
40
+ },
41
+ {
42
+ "input": "suvwdacbqxpkrgiyftl",
43
+ "output": 33
44
+ },
45
+ {
46
+ "input": "kefduqyzhgsxialp",
47
+ "output": 24
48
+ },
49
+ {
50
+ "input": "dra",
51
+ "output": 3
52
+ },
53
+ {
54
+ "input": "djvt",
55
+ "output": 4
56
+ },
57
+ {
58
+ "input": "bzimqfatksyuoer",
59
+ "output": 22
60
+ }
61
+ ],
62
+ "haskell_template": "minimumPushes :: String -> Int\nminimumPushes word ",
63
+ "ocaml_template": "let minimumPushes (word: string) : int = ",
64
+ "scala_template": "def minimumPushes(word: String): Int = { \n \n}",
65
+ "java_template": "class Solution {\n public int minimumPushes(String word) {\n \n }\n}",
66
+ "python_template": "class Solution(object):\n def minimumPushes(self, word):\n \"\"\"\n :type word: str\n :rtype: int\n \"\"\"\n "
67
+ }
minimum_number_of_pushes_to_type_word_i/ocaml_tests/main.ml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let minimumPushes (word: string) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 5 (minimumPushes "abcde")
13
+
14
+ let test2 _ = assert_equal 12 (minimumPushes "xycdefghij")
15
+
16
+ let test3 _ = assert_equal 12 (minimumPushes "ytpmlveqaorscn")
17
+
18
+ let test4 _ = assert_equal 12 (minimumPushes "oabctkjnyrqlvsfmgwux")
19
+
20
+ let test5 _ = assert_equal 12 (minimumPushes "fzrqwode")
21
+
22
+ let test6 _ = assert_equal 12 (minimumPushes "gcnmiyrdhzvk")
23
+
24
+ let test7 _ = assert_equal 12 (minimumPushes "kpsahebnwdo")
25
+
26
+ let test8 _ = assert_equal 12 (minimumPushes "suvwdacbqxpkrgiyftl")
27
+
28
+ let test9 _ = assert_equal 12 (minimumPushes "kefduqyzhgsxialp")
29
+
30
+ let test10 _ = assert_equal 12 (minimumPushes "dra")
31
+
32
+
33
+ (* Grouping test cases *)
34
+ let suite = "Test Suite for minimumPushes" >::: [
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_number_of_pushes_to_type_word_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.minimumPushes("abcde"), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.minimumPushes("xycdefghij"), 12)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.minimumPushes(",y,t,p,m,l,v,e,q,a,o,r,s,c,n,"), 20)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.minimumPushes(",o,a,b,c,t,k,j,n,y,r,q,l,v,s,f,m,g,w,u,x,"), 36)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.minimumPushes(",f,z,r,q,w,o,d,e,"), 8)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.minimumPushes(",g,c,n,m,i,y,r,d,h,z,v,k,"), 16)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.minimumPushes(",k,p,s,a,h,e,b,n,w,d,o,"), 14)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.minimumPushes(",s,u,v,w,d,a,c,b,q,x,p,k,r,g,i,y,f,t,l,"), 33)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.minimumPushes(",k,e,f,d,u,q,y,z,h,g,s,x,i,a,l,p,"), 24)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.minimumPushes(",d,r,a,"), 3)
42
+ }
43
+
44
+ }
minimum_number_of_pushes_to_type_word_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_pushes_to_type_word_ii/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(5, minimumPushes("abcde"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(12, minimumPushes("xyzxyzxyzxyz"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(24, minimumPushes("aabbccddeeffgghhiiiiii"));
22
+ }
23
+
24
+ }
minimum_number_of_pushes_to_type_word_ii/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_pushes_to_type_word_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_pushes_to_type_word_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_seconds_to_make_mountain_height_zero/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_seconds_to_make_mountain_height_zero/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, minNumberOfSeconds(4, new ArrayList<>(Arrays.asList(2,1,1))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(12, minNumberOfSeconds(10, new ArrayList<>(Arrays.asList(3,2,2,4))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(15, minNumberOfSeconds(5, new ArrayList<>(Arrays.asList(1))));
23
+ }
24
+
25
+ }
minimum_number_of_seconds_to_make_mountain_height_zero/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_seconds_to_make_mountain_height_zero/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_seconds_to_make_mountain_height_zero/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
minimum_number_of_steps_to_make_two_strings_anagram_ii/.DS_Store ADDED
Binary file (6.15 kB). View file