DatasetRepo commited on
Commit
e34635f
·
verified ·
1 Parent(s): da5f12f

803548b7eea7d7363140b6f8aaf57360f973ef32663c952b21e1c1c24baa9bf5

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 +7 -0
  2. maximum_subsequence_score/haskell_tests/Main.hs +0 -0
  3. maximum_subsequence_score/java_tests/Main.java +21 -0
  4. maximum_subsequence_score/meta.json +0 -0
  5. maximum_subsequence_score/ocaml_tests/main.ml +0 -0
  6. maximum_subsequence_score/scala_tests/MySuite.scala +0 -0
  7. maximum_sum_of_almost_unique_subarray/.DS_Store +0 -0
  8. maximum_sum_of_almost_unique_subarray/haskell_tests/Main.hs +27 -0
  9. maximum_sum_of_almost_unique_subarray/java_tests/Main.java +25 -0
  10. maximum_sum_of_almost_unique_subarray/meta.json +0 -0
  11. maximum_sum_of_almost_unique_subarray/ocaml_tests/main.ml +29 -0
  12. maximum_sum_of_almost_unique_subarray/scala_tests/MySuite.scala +16 -0
  13. maximum_sum_of_an_hourglass/.DS_Store +0 -0
  14. maximum_sum_of_an_hourglass/haskell_tests/Main.hs +24 -0
  15. maximum_sum_of_an_hourglass/java_tests/Main.java +21 -0
  16. maximum_sum_of_an_hourglass/meta.json +0 -0
  17. maximum_sum_of_an_hourglass/ocaml_tests/main.ml +26 -0
  18. maximum_sum_of_an_hourglass/scala_tests/MySuite.scala +12 -0
  19. maximum_sum_of_distinct_subarrays_with_length_k/.DS_Store +0 -0
  20. maximum_sum_of_distinct_subarrays_with_length_k/haskell_tests/Main.hs +24 -0
  21. maximum_sum_of_distinct_subarrays_with_length_k/java_tests/Main.java +21 -0
  22. maximum_sum_of_distinct_subarrays_with_length_k/meta.json +3 -0
  23. maximum_sum_of_distinct_subarrays_with_length_k/ocaml_tests/main.ml +26 -0
  24. maximum_sum_of_distinct_subarrays_with_length_k/scala_tests/MySuite.scala +12 -0
  25. maximum_sum_of_subsequence_with_non_adjacent_elements/haskell_tests/Main.hs +0 -0
  26. maximum_sum_of_subsequence_with_non_adjacent_elements/java_tests/Main.java +21 -0
  27. maximum_sum_of_subsequence_with_non_adjacent_elements/meta.json +3 -0
  28. maximum_sum_of_subsequence_with_non_adjacent_elements/ocaml_tests/main.ml +0 -0
  29. maximum_sum_of_subsequence_with_non_adjacent_elements/scala_tests/MySuite.scala +0 -0
  30. maximum_sum_queries/haskell_tests/Main.hs +3 -0
  31. maximum_sum_queries/java_tests/Main.java +25 -0
  32. maximum_sum_queries/meta.json +3 -0
  33. maximum_sum_queries/ocaml_tests/main.ml +3 -0
  34. maximum_sum_queries/scala_tests/MySuite.scala +3 -0
  35. maximum_sum_with_at_most_k_elements/haskell_tests/Main.hs +45 -0
  36. maximum_sum_with_at_most_k_elements/java_tests/Main.java +21 -0
  37. maximum_sum_with_at_most_k_elements/meta.json +409 -0
  38. maximum_sum_with_at_most_k_elements/ocaml_tests/main.ml +47 -0
  39. maximum_sum_with_at_most_k_elements/scala_tests/MySuite.scala +40 -0
  40. maximum_sum_with_exactly_k_elements/haskell_tests/Main.hs +45 -0
  41. maximum_sum_with_exactly_k_elements/java_tests/Main.java +21 -0
  42. maximum_sum_with_exactly_k_elements/meta.json +718 -0
  43. maximum_sum_with_exactly_k_elements/ocaml_tests/main.ml +50 -0
  44. maximum_sum_with_exactly_k_elements/scala_tests/MySuite.scala +44 -0
  45. maximum_tastiness_of_candy_basket/.DS_Store +0 -0
  46. maximum_tastiness_of_candy_basket/haskell_tests/Main.hs +27 -0
  47. maximum_tastiness_of_candy_basket/java_tests/Main.java +25 -0
  48. maximum_tastiness_of_candy_basket/meta.json +3 -0
  49. maximum_tastiness_of_candy_basket/ocaml_tests/main.ml +29 -0
  50. maximum_tastiness_of_candy_basket/scala_tests/MySuite.scala +16 -0
.gitattributes CHANGED
@@ -191,3 +191,10 @@ maximum_score_of_a_node_sequence/meta.json filter=lfs diff=lfs merge=lfs -text
191
  maximum_star_sum_of_a_graph/meta.json filter=lfs diff=lfs merge=lfs -text
192
  maximum_subarray_sum_with_length_divisible_by_k/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
193
  maximum_subarray_sum_with_length_divisible_by_k/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
191
  maximum_star_sum_of_a_graph/meta.json filter=lfs diff=lfs merge=lfs -text
192
  maximum_subarray_sum_with_length_divisible_by_k/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
193
  maximum_subarray_sum_with_length_divisible_by_k/meta.json filter=lfs diff=lfs merge=lfs -text
194
+ maximum_sum_of_distinct_subarrays_with_length_k/meta.json filter=lfs diff=lfs merge=lfs -text
195
+ maximum_sum_of_subsequence_with_non_adjacent_elements/meta.json filter=lfs diff=lfs merge=lfs -text
196
+ maximum_sum_queries/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
197
+ maximum_sum_queries/meta.json filter=lfs diff=lfs merge=lfs -text
198
+ maximum_sum_queries/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
199
+ maximum_sum_queries/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
200
+ maximum_tastiness_of_candy_basket/meta.json filter=lfs diff=lfs merge=lfs -text
maximum_subsequence_score/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
maximum_subsequence_score/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(12, maxScore(new ArrayList<>(Arrays.asList(1,3,3,2)), new ArrayList<>(Arrays.asList(2,1,3,4)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(30, maxScore(new ArrayList<>(Arrays.asList(4,2,3,1,1)), new ArrayList<>(Arrays.asList(7,5,10,9,6)), 1));
19
+ }
20
+
21
+ }
maximum_subsequence_score/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
maximum_subsequence_score/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
maximum_subsequence_score/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_of_almost_unique_subarray/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_sum_of_almost_unique_subarray/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 (maxSum [2,6,7,3,1,7] 3 4)," 18 (maxSum [2,6,7,3,1,7] 3 4))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maxSum [5,9,9,2,4,5,4] 1 3)," 23 (maxSum [5,9,9,2,4,5,4] 1 3))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maxSum [1,2,1,2,1,2,1] 3 3)," 0 (maxSum [1,2,1,2,1,2,1] 3 3))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
maximum_sum_of_almost_unique_subarray/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(18, maxSum(new ArrayList<>(Arrays.asList(2,6,7,3,1,7)), 3, 4));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(23, maxSum(new ArrayList<>(Arrays.asList(5,9,9,2,4,5,4)), 1, 3));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, maxSum(new ArrayList<>(Arrays.asList(1,2,1,2,1,2,1)), 3, 3));
23
+ }
24
+
25
+ }
maximum_sum_of_almost_unique_subarray/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_of_almost_unique_subarray/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 18 (maxSum [2;6;7;3;1;7] 3 4)
12
+
13
+ let test2 _ = assert_equal 23 (maxSum [5;9;9;2;4;5;4] 1 3)
14
+
15
+ let test3 _ = assert_equal 0 (maxSum [1;2;1;2;1;2;1] 3 3)
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for maxSum" >::: [
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
maximum_sum_of_almost_unique_subarray/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxSum(List(2,6,7,3,1,7),3,4), 18)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxSum(List(5,9,9,2,4,5,4),1,3), 23)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maxSum(List(1,2,1,2,1,2,1),3,3), 0)
14
+ }
15
+
16
+ }
maximum_sum_of_an_hourglass/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_sum_of_an_hourglass/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 (maxSum [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]])," 30 (maxSum [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maxSum [[1,2,3],[4,5,6],[7,8,9]])," 35 (maxSum [[1,2,3],[4,5,6],[7,8,9]]))
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
maximum_sum_of_an_hourglass/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(30, maxSum(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(6,2,1,3)),new ArrayList<>(Arrays.asList(4,2,1,5)),new ArrayList<>(Arrays.asList(9,2,8,7)),new ArrayList<>(Arrays.asList(4,1,2,9))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(35, maxSum(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,3)),new ArrayList<>(Arrays.asList(4,5,6)),new ArrayList<>(Arrays.asList(7,8,9))))));
19
+ }
20
+
21
+ }
maximum_sum_of_an_hourglass/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_of_an_hourglass/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 30 (maxSum [[6;2;1;3];[4;2;1;5];[9;2;8;7];[4;1;2;9]])
12
+
13
+ let test2 _ = assert_equal 35 (maxSum [[1;2;3];[4;5;6];[7;8;9]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maxSum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_sum_of_an_hourglass/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxSum(List(List(6,2,1,3),List(4,2,1,5),List(9,2,8,7),List(4,1,2,9))), 30)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxSum(List(List(1,2,3),List(4,5,6),List(7,8,9))), 35)
10
+ }
11
+
12
+ }
maximum_sum_of_distinct_subarrays_with_length_k/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_sum_of_distinct_subarrays_with_length_k/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (maximumSubarraySum [1,5,4,2,9,9,9] 3)," 15 (maximumSubarraySum [1,5,4,2,9,9,9] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumSubarraySum [4,4,4] 3)," 0 (maximumSubarraySum [4,4,4] 3))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
maximum_sum_of_distinct_subarrays_with_length_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(15, maximumSubarraySum(new ArrayList<>(Arrays.asList(1,5,4,2,9,9,9)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, maximumSubarraySum(new ArrayList<>(Arrays.asList(4,4,4)), 3));
19
+ }
20
+
21
+ }
maximum_sum_of_distinct_subarrays_with_length_k/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:770be52752510b42b9bde431c460657590ae7d57b2a300b100e5b297011dbc35
3
+ size 15585391
maximum_sum_of_distinct_subarrays_with_length_k/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 15 (maximumSubarraySum [1;5;4;2;9;9;9] 3)
12
+
13
+ let test2 _ = assert_equal 0 (maximumSubarraySum [4;4;4] 3)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maximumSubarraySum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_sum_of_distinct_subarrays_with_length_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumSubarraySum(List(1,5,4,2,9,9,9),3), 15)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumSubarraySum(List(4,4,4),3), 0)
10
+ }
11
+
12
+ }
maximum_sum_of_subsequence_with_non_adjacent_elements/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_of_subsequence_with_non_adjacent_elements/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(21, maximumSumSubsequence(new ArrayList<>(Arrays.asList(3,5,9)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,-2)),new ArrayList<>(Arrays.asList(0,-3))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, maximumSumSubsequence(new ArrayList<>(Arrays.asList(0,-1)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,-5))))));
19
+ }
20
+
21
+ }
maximum_sum_of_subsequence_with_non_adjacent_elements/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a64aaea4c45cf9d55accf871c8296b73cfd439581425ff1d912c20eb85a86d06
3
+ size 37965603
maximum_sum_of_subsequence_with_non_adjacent_elements/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_of_subsequence_with_non_adjacent_elements/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
maximum_sum_queries/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4795d966ae8496085b05cf6df5ea36245807002376c3f49e6901c1241e3f1587
3
+ size 33639166
maximum_sum_queries/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(6,10,7)), maximumSumQueries(new ArrayList<>(Arrays.asList(4,3,1,2)), new ArrayList<>(Arrays.asList(2,4,9,5)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(4,1)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(2,5))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(9,9,9)), maximumSumQueries(new ArrayList<>(Arrays.asList(3,2,5)), new ArrayList<>(Arrays.asList(2,3,4)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(4,4)),new ArrayList<>(Arrays.asList(3,2)),new ArrayList<>(Arrays.asList(1,1))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(Arrays.asList(-1)), maximumSumQueries(new ArrayList<>(Arrays.asList(2,1)), new ArrayList<>(Arrays.asList(2,3)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,3))))));
23
+ }
24
+
25
+ }
maximum_sum_queries/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7b2e36ba3b36e87d55961f414ab7ce771a4b979e368eaa25fc814587242ba53
3
+ size 69327176
maximum_sum_queries/ocaml_tests/main.ml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3415fd81a1da629fc3d6fb4680dc982a65c7ebfd57e0638b651886b4a7315857
3
+ size 19878542
maximum_sum_queries/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5cf3d15f7d041ef80491526c8a2abe004de1178f7bb49e6150c5b14e54339ad
3
+ size 21078116
maximum_sum_with_at_most_k_elements/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 (maxSum [[1,2],[3,4]] [1,2] 2)," 7 (maxSum [[1,2],[3,4]] [1,2] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maxSum [[5,3,7],[8,2,6]] [2,2] 3)," 21 (maxSum [[5,3,7],[8,2,6]] [2,2] 3))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maxSum [[85260, 47422, 53625, 36747, 35594, 28797, 17386, 17212], [88531, 85530, 76965, 73095, 91830, 57035, 40917, 6379], [76486, 96359, 67702, 37662, 34499, 67026, 21931, 60146], [82976, 94923, 40907, 40371, 26172, 18157, 11966, 8383], [99722, 97724, 96166, 95370, 91702, 63781, 38317, 18411]] [8, 8, 3, 7, 6] 31)," 1936430 (maxSum [[85260, 47422, 53625, 36747, 35594, 28797, 17386, 17212], [88531, 85530, 76965, 73095, 91830, 57035, 40917, 6379], [76486, 96359, 67702, 37662, 34499, 67026, 21931, 60146], [82976, 94923, 40907, 40371, 26172, 18157, 11966, 8383], [99722, 97724, 96166, 95370, 91702, 63781, 38317, 18411]] [8, 8, 3, 7, 6] 31))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (maxSum [[99201, 75381, 25786, 47568, 39575, 53131, 20846, 30443]] [8] 0)," 0 (maxSum [[99201, 75381, 25786, 47568, 39575, 53131, 20846, 30443]] [8] 0))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (maxSum [[99113, 51916, 65503, 68687, 99547, 44294, 30149, 15959, 12781, 9287], [99043, 63459, 87093, 73661, 61210, 37723, 54030, 25083, 23938, 2843], [91499, 87846, 81731, 22610, 7877, 60272, 27361, 34701, 72751, 74092]] [9, 10, 3] 13)," 1032422 (maxSum [[99113, 51916, 65503, 68687, 99547, 44294, 30149, 15959, 12781, 9287], [99043, 63459, 87093, 73661, 61210, 37723, 54030, 25083, 23938, 2843], [91499, 87846, 81731, 22610, 7877, 60272, 27361, 34701, 72751, 74092]] [9, 10, 3] 13))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (maxSum [[77396, 71185, 66579, 53915, 45338, 34468, 33748, 23063, 14847], [88748, 57775, 57304, 55690, 5133, 26276, 33951, 9134, 49841], [86127, 99185, 91542, 89987, 81543, 67434, 38706, 35201, 16325], [85292, 84558, 84422, 57679, 81955, 80105, 15526, 22631, 40387], [97944, 80230, 69185, 66814, 66562, 40888, 26192, 5613, 3978], [97593, 36018, 34869, 34595, 23256, 19245, 12121, 5355, 13820], [83024, 55292, 54488, 47889, 40427, 26477, 13105, 10965, 10807], [38292, 94372, 72810, 53385, 38900, 36304, 21241, 17594, 21171], [98046, 55130, 95850, 63201, 65030, 55271, 42742, 39030, 13609]] [6, 4, 8, 2, 5, 5, 4, 6, 7] 20)," 1712051 (maxSum [[77396, 71185, 66579, 53915, 45338, 34468, 33748, 23063, 14847], [88748, 57775, 57304, 55690, 5133, 26276, 33951, 9134, 49841], [86127, 99185, 91542, 89987, 81543, 67434, 38706, 35201, 16325], [85292, 84558, 84422, 57679, 81955, 80105, 15526, 22631, 40387], [97944, 80230, 69185, 66814, 66562, 40888, 26192, 5613, 3978], [97593, 36018, 34869, 34595, 23256, 19245, 12121, 5355, 13820], [83024, 55292, 54488, 47889, 40427, 26477, 13105, 10965, 10807], [38292, 94372, 72810, 53385, 38900, 36304, 21241, 17594, 21171], [98046, 55130, 95850, 63201, 65030, 55271, 42742, 39030, 13609]] [6, 4, 8, 2, 5, 5, 4, 6, 7] 20))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (maxSum [[64638], [94336], [25444], [54487], [66368], [95785]] [1, 0, 0, 0, 0, 1] 1)," 95785 (maxSum [[64638], [94336], [25444], [54487], [66368], [95785]] [1, 0, 0, 0, 0, 1] 1))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (maxSum [[92742, 80876, 68577, 45679, 7633, 15336], [86141, 70975, 48255, 37017, 34398, 12550], [85980, 60142, 41618, 31614, 28519, 12337], [71522, 88380, 52692, 44141, 42349, 35045], [96109, 84777, 56237, 48867, 33293, 20946]] [2, 3, 1, 3, 2] 8)," 686527 (maxSum [[92742, 80876, 68577, 45679, 7633, 15336], [86141, 70975, 48255, 37017, 34398, 12550], [85980, 60142, 41618, 31614, 28519, 12337], [71522, 88380, 52692, 44141, 42349, 35045], [96109, 84777, 56237, 48867, 33293, 20946]] [2, 3, 1, 3, 2] 8))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (maxSum [[74678, 20231, 19180], [82050, 20624, 7449], [84397, 29107, 2718], [90313, 39443, 25013], [67980, 17651, 6582]] [1, 1, 2, 2, 1] 1)," 90313 (maxSum [[74678, 20231, 19180], [82050, 20624, 7449], [84397, 29107, 2718], [90313, 39443, 25013], [67980, 17651, 6582]] [1, 1, 2, 2, 1] 1))
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]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
maximum_sum_with_at_most_k_elements/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(7, maxSum(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(3,4)))), new ArrayList<>(Arrays.asList(1,2)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(21, maxSum(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,3,7)),new ArrayList<>(Arrays.asList(8,2,6)))), new ArrayList<>(Arrays.asList(2,2)), 3));
19
+ }
20
+
21
+ }
maximum_sum_with_at_most_k_elements/meta.json ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3764,
3
+ "name": "maximum_sum_with_at_most_k_elements",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/maximum-sum-with-at-most-k-elements/",
6
+ "date": "2025-02-16 00:00:00",
7
+ "task_description": "You are given a 2D integer matrix `grid` of size `n x m`, an integer array `limits` of length `n`, and an integer `k`. The task is to find the **maximum sum** of **at most** `k` elements from the matrix `grid` such that: The number of elements taken from the `ith` row of `grid` does not exceed `limits[i]`. Return the **maximum sum**. **Example 1:** **Input:** grid = [[1,2],[3,4]], limits = [1,2], k = 2 **Output:** 7 **Explanation:** From the second row, we can take at most 2 elements. The elements taken are 4 and 3. The maximum possible sum of at most 2 selected elements is `4 + 3 = 7`. **Example 2:** **Input:** grid = [[5,3,7],[8,2,6]], limits = [2,2], k = 3 **Output:** 21 **Explanation:** From the first row, we can take at most 2 elements. The element taken is 7. From the second row, we can take at most 2 elements. The elements taken are 8 and 6. The maximum possible sum of at most 3 selected elements is `7 + 8 + 6 = 21`. **Constraints:** `n == grid.length == limits.length` `m == grid[i].length` `1 <= n, m <= 500` `0 <= grid[i][j] <= 105` `0 <= limits[i] <= m` `0 <= k <= min(n * m, sum(limits))`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "grid = [[1,2],[3,4]], limits = [1,2], k = 2",
12
+ "output": "7 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "grid = [[5,3,7],[8,2,6]], limits = [2,2], k = 3",
17
+ "output": "21 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ [
25
+ 85260,
26
+ 47422,
27
+ 53625,
28
+ 36747,
29
+ 35594,
30
+ 28797,
31
+ 17386,
32
+ 17212
33
+ ],
34
+ [
35
+ 88531,
36
+ 85530,
37
+ 76965,
38
+ 73095,
39
+ 91830,
40
+ 57035,
41
+ 40917,
42
+ 6379
43
+ ],
44
+ [
45
+ 76486,
46
+ 96359,
47
+ 67702,
48
+ 37662,
49
+ 34499,
50
+ 67026,
51
+ 21931,
52
+ 60146
53
+ ],
54
+ [
55
+ 82976,
56
+ 94923,
57
+ 40907,
58
+ 40371,
59
+ 26172,
60
+ 18157,
61
+ 11966,
62
+ 8383
63
+ ],
64
+ [
65
+ 99722,
66
+ 97724,
67
+ 96166,
68
+ 95370,
69
+ 91702,
70
+ 63781,
71
+ 38317,
72
+ 18411
73
+ ]
74
+ ],
75
+ [
76
+ 8,
77
+ 8,
78
+ 3,
79
+ 7,
80
+ 6
81
+ ],
82
+ 31
83
+ ],
84
+ "output": 1936430
85
+ },
86
+ {
87
+ "input": [
88
+ [
89
+ [
90
+ 99201,
91
+ 75381,
92
+ 25786,
93
+ 47568,
94
+ 39575,
95
+ 53131,
96
+ 20846,
97
+ 30443
98
+ ]
99
+ ],
100
+ [
101
+ 8
102
+ ],
103
+ 0
104
+ ],
105
+ "output": 0
106
+ },
107
+ {
108
+ "input": [
109
+ [
110
+ [
111
+ 99113,
112
+ 51916,
113
+ 65503,
114
+ 68687,
115
+ 99547,
116
+ 44294,
117
+ 30149,
118
+ 15959,
119
+ 12781,
120
+ 9287
121
+ ],
122
+ [
123
+ 99043,
124
+ 63459,
125
+ 87093,
126
+ 73661,
127
+ 61210,
128
+ 37723,
129
+ 54030,
130
+ 25083,
131
+ 23938,
132
+ 2843
133
+ ],
134
+ [
135
+ 91499,
136
+ 87846,
137
+ 81731,
138
+ 22610,
139
+ 7877,
140
+ 60272,
141
+ 27361,
142
+ 34701,
143
+ 72751,
144
+ 74092
145
+ ]
146
+ ],
147
+ [
148
+ 9,
149
+ 10,
150
+ 3
151
+ ],
152
+ 13
153
+ ],
154
+ "output": 1032422
155
+ },
156
+ {
157
+ "input": [
158
+ [
159
+ [
160
+ 77396,
161
+ 71185,
162
+ 66579,
163
+ 53915,
164
+ 45338,
165
+ 34468,
166
+ 33748,
167
+ 23063,
168
+ 14847
169
+ ],
170
+ [
171
+ 88748,
172
+ 57775,
173
+ 57304,
174
+ 55690,
175
+ 5133,
176
+ 26276,
177
+ 33951,
178
+ 9134,
179
+ 49841
180
+ ],
181
+ [
182
+ 86127,
183
+ 99185,
184
+ 91542,
185
+ 89987,
186
+ 81543,
187
+ 67434,
188
+ 38706,
189
+ 35201,
190
+ 16325
191
+ ],
192
+ [
193
+ 85292,
194
+ 84558,
195
+ 84422,
196
+ 57679,
197
+ 81955,
198
+ 80105,
199
+ 15526,
200
+ 22631,
201
+ 40387
202
+ ],
203
+ [
204
+ 97944,
205
+ 80230,
206
+ 69185,
207
+ 66814,
208
+ 66562,
209
+ 40888,
210
+ 26192,
211
+ 5613,
212
+ 3978
213
+ ],
214
+ [
215
+ 97593,
216
+ 36018,
217
+ 34869,
218
+ 34595,
219
+ 23256,
220
+ 19245,
221
+ 12121,
222
+ 5355,
223
+ 13820
224
+ ],
225
+ [
226
+ 83024,
227
+ 55292,
228
+ 54488,
229
+ 47889,
230
+ 40427,
231
+ 26477,
232
+ 13105,
233
+ 10965,
234
+ 10807
235
+ ],
236
+ [
237
+ 38292,
238
+ 94372,
239
+ 72810,
240
+ 53385,
241
+ 38900,
242
+ 36304,
243
+ 21241,
244
+ 17594,
245
+ 21171
246
+ ],
247
+ [
248
+ 98046,
249
+ 55130,
250
+ 95850,
251
+ 63201,
252
+ 65030,
253
+ 55271,
254
+ 42742,
255
+ 39030,
256
+ 13609
257
+ ]
258
+ ],
259
+ [
260
+ 6,
261
+ 4,
262
+ 8,
263
+ 2,
264
+ 5,
265
+ 5,
266
+ 4,
267
+ 6,
268
+ 7
269
+ ],
270
+ 20
271
+ ],
272
+ "output": 1712051
273
+ },
274
+ {
275
+ "input": [
276
+ [
277
+ [
278
+ 64638
279
+ ],
280
+ [
281
+ 94336
282
+ ],
283
+ [
284
+ 25444
285
+ ],
286
+ [
287
+ 54487
288
+ ],
289
+ [
290
+ 66368
291
+ ],
292
+ [
293
+ 95785
294
+ ]
295
+ ],
296
+ [
297
+ 1,
298
+ 0,
299
+ 0,
300
+ 0,
301
+ 0,
302
+ 1
303
+ ],
304
+ 1
305
+ ],
306
+ "output": 95785
307
+ },
308
+ {
309
+ "input": [
310
+ [
311
+ [
312
+ 92742,
313
+ 80876,
314
+ 68577,
315
+ 45679,
316
+ 7633,
317
+ 15336
318
+ ],
319
+ [
320
+ 86141,
321
+ 70975,
322
+ 48255,
323
+ 37017,
324
+ 34398,
325
+ 12550
326
+ ],
327
+ [
328
+ 85980,
329
+ 60142,
330
+ 41618,
331
+ 31614,
332
+ 28519,
333
+ 12337
334
+ ],
335
+ [
336
+ 71522,
337
+ 88380,
338
+ 52692,
339
+ 44141,
340
+ 42349,
341
+ 35045
342
+ ],
343
+ [
344
+ 96109,
345
+ 84777,
346
+ 56237,
347
+ 48867,
348
+ 33293,
349
+ 20946
350
+ ]
351
+ ],
352
+ [
353
+ 2,
354
+ 3,
355
+ 1,
356
+ 3,
357
+ 2
358
+ ],
359
+ 8
360
+ ],
361
+ "output": 686527
362
+ },
363
+ {
364
+ "input": [
365
+ [
366
+ [
367
+ 74678,
368
+ 20231,
369
+ 19180
370
+ ],
371
+ [
372
+ 82050,
373
+ 20624,
374
+ 7449
375
+ ],
376
+ [
377
+ 84397,
378
+ 29107,
379
+ 2718
380
+ ],
381
+ [
382
+ 90313,
383
+ 39443,
384
+ 25013
385
+ ],
386
+ [
387
+ 67980,
388
+ 17651,
389
+ 6582
390
+ ]
391
+ ],
392
+ [
393
+ 1,
394
+ 1,
395
+ 2,
396
+ 2,
397
+ 1
398
+ ],
399
+ 1
400
+ ],
401
+ "output": 90313
402
+ }
403
+ ],
404
+ "haskell_template": "maxSum :: [[Int]] -> [Int] -> Int -> Int\nmaxSum grid limits k ",
405
+ "ocaml_template": "let maxSum (grid: int list list) (limits: int list) (k: int) : int = ",
406
+ "scala_template": "def maxSum(grid: List[List[Int]],limits: List[Int],k: Int): Int = { \n \n}",
407
+ "java_template": "class Solution {\n public long maxSum(int[][] grid, int[] limits, int k) {\n \n }\n}",
408
+ "python_template": "class Solution(object):\n def maxSum(self, grid, limits, k):\n \"\"\"\n :type grid: List[List[int]]\n :type limits: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
409
+ }
maximum_sum_with_at_most_k_elements/ocaml_tests/main.ml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 7 (maxSum [[1;2];[3;4]] [1;2] 2)
12
+
13
+ let test2 _ = assert_equal 21 (maxSum [[5;3;7];[8;2;6]] [2;2] 3)
14
+
15
+ let test3 _ = assert_equal 1936430 (maxSum [[85260; 47422; 53625; 36747; 35594; 28797; 17386; 17212]; [88531; 85530; 76965; 73095; 91830; 57035; 40917; 6379]; [76486; 96359; 67702; 37662; 34499; 67026; 21931; 60146]; [82976; 94923; 40907; 40371; 26172; 18157; 11966; 8383]; [99722; 97724; 96166; 95370; 91702; 63781; 38317; 18411]] [8; 8; 3; 7; 6] 31)
16
+
17
+ let test4 _ = assert_equal 0 (maxSum [[99201; 75381; 25786; 47568; 39575; 53131; 20846; 30443]] [8] 0)
18
+
19
+ let test5 _ = assert_equal 1032422 (maxSum [[99113; 51916; 65503; 68687; 99547; 44294; 30149; 15959; 12781; 9287]; [99043; 63459; 87093; 73661; 61210; 37723; 54030; 25083; 23938; 2843]; [91499; 87846; 81731; 22610; 7877; 60272; 27361; 34701; 72751; 74092]] [9; 10; 3] 13)
20
+
21
+ let test6 _ = assert_equal 1712051 (maxSum [[77396; 71185; 66579; 53915; 45338; 34468; 33748; 23063; 14847]; [88748; 57775; 57304; 55690; 5133; 26276; 33951; 9134; 49841]; [86127; 99185; 91542; 89987; 81543; 67434; 38706; 35201; 16325]; [85292; 84558; 84422; 57679; 81955; 80105; 15526; 22631; 40387]; [97944; 80230; 69185; 66814; 66562; 40888; 26192; 5613; 3978]; [97593; 36018; 34869; 34595; 23256; 19245; 12121; 5355; 13820]; [83024; 55292; 54488; 47889; 40427; 26477; 13105; 10965; 10807]; [38292; 94372; 72810; 53385; 38900; 36304; 21241; 17594; 21171]; [98046; 55130; 95850; 63201; 65030; 55271; 42742; 39030; 13609]] [6; 4; 8; 2; 5; 5; 4; 6; 7] 20)
22
+
23
+ let test7 _ = assert_equal 95785 (maxSum [[64638]; [94336]; [25444]; [54487]; [66368]; [95785]] [1; 0; 0; 0; 0; 1] 1)
24
+
25
+ let test8 _ = assert_equal 686527 (maxSum [[92742; 80876; 68577; 45679; 7633; 15336]; [86141; 70975; 48255; 37017; 34398; 12550]; [85980; 60142; 41618; 31614; 28519; 12337]; [71522; 88380; 52692; 44141; 42349; 35045]; [96109; 84777; 56237; 48867; 33293; 20946]] [2; 3; 1; 3; 2] 8)
26
+
27
+ let test9 _ = assert_equal 90313 (maxSum [[74678; 20231; 19180]; [82050; 20624; 7449]; [84397; 29107; 2718]; [90313; 39443; 25013]; [67980; 17651; 6582]] [1; 1; 2; 2; 1] 1)
28
+
29
+
30
+ (* Grouping test cases *)
31
+ let suite = "Test Suite for maxSum" >::: [
32
+
33
+ "test1" >:: test1;
34
+ "test2" >:: test2;
35
+ "test3" >:: test3;
36
+ "test4" >:: test4;
37
+ "test5" >:: test5;
38
+ "test6" >:: test6;
39
+ "test7" >:: test7;
40
+ "test8" >:: test8;
41
+ "test9" >:: test9;
42
+ ]
43
+
44
+
45
+ (* Running the tests *)
46
+ let () = run_test_tt_main suite
47
+ end
maximum_sum_with_at_most_k_elements/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxSum(List(List(1,2),List(3,4)),List(1,2),2), 7)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxSum(List(List(5,3,7),List(8,2,6)),List(2,2),3), 21)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maxSum(List(List(85260, 47422, 53625, 36747, 35594, 28797, 17386, 17212), List(88531, 85530, 76965, 73095, 91830, 57035, 40917, 6379), List(76486, 96359, 67702, 37662, 34499, 67026, 21931, 60146), List(82976, 94923, 40907, 40371, 26172, 18157, 11966, 8383), List(99722, 97724, 96166, 95370, 91702, 63781, 38317, 18411)),List(8, 8, 3, 7, 6),31), 1936430)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.maxSum(List(List(99201, 75381, 25786, 47568, 39575, 53131, 20846, 30443)),List(8),0), 0)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.maxSum(List(List(99113, 51916, 65503, 68687, 99547, 44294, 30149, 15959, 12781, 9287), List(99043, 63459, 87093, 73661, 61210, 37723, 54030, 25083, 23938, 2843), List(91499, 87846, 81731, 22610, 7877, 60272, 27361, 34701, 72751, 74092)),List(9, 10, 3),13), 1032422)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.maxSum(List(List(77396, 71185, 66579, 53915, 45338, 34468, 33748, 23063, 14847), List(88748, 57775, 57304, 55690, 5133, 26276, 33951, 9134, 49841), List(86127, 99185, 91542, 89987, 81543, 67434, 38706, 35201, 16325), List(85292, 84558, 84422, 57679, 81955, 80105, 15526, 22631, 40387), List(97944, 80230, 69185, 66814, 66562, 40888, 26192, 5613, 3978), List(97593, 36018, 34869, 34595, 23256, 19245, 12121, 5355, 13820), List(83024, 55292, 54488, 47889, 40427, 26477, 13105, 10965, 10807), List(38292, 94372, 72810, 53385, 38900, 36304, 21241, 17594, 21171), List(98046, 55130, 95850, 63201, 65030, 55271, 42742, 39030, 13609)),List(6, 4, 8, 2, 5, 5, 4, 6, 7),20), 1712051)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.maxSum(List(List(64638), List(94336), List(25444), List(54487), List(66368), List(95785)),List(1, 0, 0, 0, 0, 1),1), 95785)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.maxSum(List(List(92742, 80876, 68577, 45679, 7633, 15336), List(86141, 70975, 48255, 37017, 34398, 12550), List(85980, 60142, 41618, 31614, 28519, 12337), List(71522, 88380, 52692, 44141, 42349, 35045), List(96109, 84777, 56237, 48867, 33293, 20946)),List(2, 3, 1, 3, 2),8), 686527)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.maxSum(List(List(74678, 20231, 19180), List(82050, 20624, 7449), List(84397, 29107, 2718), List(90313, 39443, 25013), List(67980, 17651, 6582)),List(1, 1, 2, 2, 1),1), 90313)
38
+ }
39
+
40
+ }
maximum_sum_with_exactly_k_elements/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 (maximizeSum [1,2,3,4,5] 3)," 18 (maximizeSum [1,2,3,4,5] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximizeSum [5,5,5] 2)," 11 (maximizeSum [5,5,5] 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maximizeSum [49, 90, 3, 56, 32, 100, 38, 12, 5, 5, 90, 14, 20, 83, 97, 40, 69, 52, 50, 24, 82, 83, 2, 35, 20, 45, 36, 69, 22, 14, 35, 76, 50] 65)," 8580 (maximizeSum [49, 90, 3, 56, 32, 100, 38, 12, 5, 5, 90, 14, 20, 83, 97, 40, 69, 52, 50, 24, 82, 83, 2, 35, 20, 45, 36, 69, 22, 14, 35, 76, 50] 65))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (maximizeSum [44, 73, 34, 84, 91, 13, 23, 46, 6, 14, 30, 85, 75, 70, 79, 7, 60, 30, 57, 27, 59, 49] 22)," 2233 (maximizeSum [44, 73, 34, 84, 91, 13, 23, 46, 6, 14, 30, 85, 75, 70, 79, 7, 60, 30, 57, 27, 59, 49] 22))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (maximizeSum [81, 14, 40, 34, 54, 23, 63, 65, 84, 84, 4, 37, 88, 41, 8, 33, 54, 18, 49, 67, 85, 37, 78, 46, 38, 80, 13, 77, 93, 5, 3, 12, 89, 36, 44, 63, 41, 22, 95, 86, 11, 44, 74, 82, 48, 57, 90, 35, 44, 46, 71, 66, 6, 3, 1, 26, 38, 47, 70, 24, 3, 54, 67, 48, 89, 4, 57, 41, 69, 77, 24, 74, 26, 78, 67, 22, 84] 71)," 9230 (maximizeSum [81, 14, 40, 34, 54, 23, 63, 65, 84, 84, 4, 37, 88, 41, 8, 33, 54, 18, 49, 67, 85, 37, 78, 46, 38, 80, 13, 77, 93, 5, 3, 12, 89, 36, 44, 63, 41, 22, 95, 86, 11, 44, 74, 82, 48, 57, 90, 35, 44, 46, 71, 66, 6, 3, 1, 26, 38, 47, 70, 24, 3, 54, 67, 48, 89, 4, 57, 41, 69, 77, 24, 74, 26, 78, 67, 22, 84] 71))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (maximizeSum [12, 50, 78, 77, 47, 31, 50, 24, 58, 8, 53, 44, 27, 74, 1, 64, 44, 64, 87, 93, 1, 71, 56, 29, 35, 99, 95, 57, 86, 90, 78, 95, 29, 1, 26, 5, 51, 43, 84, 58, 29, 66, 74, 36, 6, 69, 67, 63, 2, 77, 47, 12, 22, 13, 13, 100, 66, 92, 32, 76, 66, 71, 40, 64, 63, 76, 7, 2, 100, 5, 53, 14, 21, 44, 37, 21, 97, 38, 31, 22] 58)," 7453 (maximizeSum [12, 50, 78, 77, 47, 31, 50, 24, 58, 8, 53, 44, 27, 74, 1, 64, 44, 64, 87, 93, 1, 71, 56, 29, 35, 99, 95, 57, 86, 90, 78, 95, 29, 1, 26, 5, 51, 43, 84, 58, 29, 66, 74, 36, 6, 69, 67, 63, 2, 77, 47, 12, 22, 13, 13, 100, 66, 92, 32, 76, 66, 71, 40, 64, 63, 76, 7, 2, 100, 5, 53, 14, 21, 44, 37, 21, 97, 38, 31, 22] 58))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (maximizeSum [3, 69, 95, 56, 57, 13, 12, 63, 17, 22, 96, 67, 5, 32, 79, 5, 43, 39, 26, 53, 32, 82, 95, 1, 68, 94, 21, 93, 54, 75, 36, 19, 43, 93, 5, 16, 28, 84, 17, 44, 11, 96, 73, 37, 54, 92, 79, 56, 58, 33, 82, 67, 44, 82, 41, 83, 55, 42, 16, 46] 75)," 9975 (maximizeSum [3, 69, 95, 56, 57, 13, 12, 63, 17, 22, 96, 67, 5, 32, 79, 5, 43, 39, 26, 53, 32, 82, 95, 1, 68, 94, 21, 93, 54, 75, 36, 19, 43, 93, 5, 16, 28, 84, 17, 44, 11, 96, 73, 37, 54, 92, 79, 56, 58, 33, 82, 67, 44, 82, 41, 83, 55, 42, 16, 46] 75))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (maximizeSum [47, 16, 81, 75, 82, 87, 11, 52, 71, 8, 61, 31, 52, 38, 55, 74, 89, 15, 9, 49, 48, 87, 36, 84, 45, 77, 92, 24, 37, 64, 40, 29, 18, 87, 95, 80, 41, 84, 12, 76, 75, 90, 13, 65, 84] 15)," 1530 (maximizeSum [47, 16, 81, 75, 82, 87, 11, 52, 71, 8, 61, 31, 52, 38, 55, 74, 89, 15, 9, 49, 48, 87, 36, 84, 45, 77, 92, 24, 37, 64, 40, 29, 18, 87, 95, 80, 41, 84, 12, 76, 75, 90, 13, 65, 84] 15))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (maximizeSum [98, 56, 51, 95, 91, 66, 51, 40, 34, 51, 7, 48, 37, 61] 5)," 500 (maximizeSum [98, 56, 51, 95, 91, 66, 51, 40, 34, 51, 7, 48, 37, 61] 5))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
maximum_sum_with_exactly_k_elements/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(18, maximizeSum(new ArrayList<>(Arrays.asList(1,2,3,4,5)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(11, maximizeSum(new ArrayList<>(Arrays.asList(5,5,5)), 2));
19
+ }
20
+
21
+ }
maximum_sum_with_exactly_k_elements/meta.json ADDED
@@ -0,0 +1,718 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2767,
3
+ "name": "maximum_sum_with_exactly_k_elements",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/maximum-sum-with-exactly-k-elements/",
6
+ "date": "2023-04-15 00:00:00",
7
+ "task_description": "You are given a **0-indexed** integer array `nums` and an integer `k`. Your task is to perform the following operation **exactly** `k` times in order to maximize your score: Select an element `m` from `nums`. Remove the selected element `m` from the array. Add a new element with a value of `m + 1` to the array. Increase your score by `m`. Return _the maximum score you can achieve after performing the operation exactly_ `k` _times._ **Example 1:** ``` **Input:** nums = [1,2,3,4,5], k = 3 **Output:** 18 **Explanation:** We need to choose exactly 3 elements from nums to maximize the sum. For the first iteration, we choose 5. Then sum is 5 and nums = [1,2,3,4,6] For the second iteration, we choose 6. Then sum is 5 + 6 and nums = [1,2,3,4,7] For the third iteration, we choose 7. Then sum is 5 + 6 + 7 = 18 and nums = [1,2,3,4,8] So, we will return 18. It can be proven, that 18 is the maximum answer that we can achieve. ``` **Example 2:** ``` **Input:** nums = [5,5,5], k = 2 **Output:** 11 **Explanation:** We need to choose exactly 2 elements from nums to maximize the sum. For the first iteration, we choose 5. Then sum is 5 and nums = [5,5,6] For the second iteration, we choose 6. Then sum is 5 + 6 = 11 and nums = [5,5,7] So, we will return 11. It can be proven, that 11 is the maximum answer that we can achieve. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100` `1 <= k <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,3,4,5], k = 3",
12
+ "output": "18 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [5,5,5], k = 2",
17
+ "output": "11 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 49,
25
+ 90,
26
+ 3,
27
+ 56,
28
+ 32,
29
+ 100,
30
+ 38,
31
+ 12,
32
+ 5,
33
+ 5,
34
+ 90,
35
+ 14,
36
+ 20,
37
+ 83,
38
+ 97,
39
+ 40,
40
+ 69,
41
+ 52,
42
+ 50,
43
+ 24,
44
+ 82,
45
+ 83,
46
+ 2,
47
+ 35,
48
+ 20,
49
+ 45,
50
+ 36,
51
+ 69,
52
+ 22,
53
+ 14,
54
+ 35,
55
+ 76,
56
+ 50
57
+ ],
58
+ 65
59
+ ],
60
+ "output": 8580
61
+ },
62
+ {
63
+ "input": [
64
+ [
65
+ 44,
66
+ 73,
67
+ 34,
68
+ 84,
69
+ 91,
70
+ 13,
71
+ 23,
72
+ 46,
73
+ 6,
74
+ 14,
75
+ 30,
76
+ 85,
77
+ 75,
78
+ 70,
79
+ 79,
80
+ 7,
81
+ 60,
82
+ 30,
83
+ 57,
84
+ 27,
85
+ 59,
86
+ 49
87
+ ],
88
+ 22
89
+ ],
90
+ "output": 2233
91
+ },
92
+ {
93
+ "input": [
94
+ [
95
+ 81,
96
+ 14,
97
+ 40,
98
+ 34,
99
+ 54,
100
+ 23,
101
+ 63,
102
+ 65,
103
+ 84,
104
+ 84,
105
+ 4,
106
+ 37,
107
+ 88,
108
+ 41,
109
+ 8,
110
+ 33,
111
+ 54,
112
+ 18,
113
+ 49,
114
+ 67,
115
+ 85,
116
+ 37,
117
+ 78,
118
+ 46,
119
+ 38,
120
+ 80,
121
+ 13,
122
+ 77,
123
+ 93,
124
+ 5,
125
+ 3,
126
+ 12,
127
+ 89,
128
+ 36,
129
+ 44,
130
+ 63,
131
+ 41,
132
+ 22,
133
+ 95,
134
+ 86,
135
+ 11,
136
+ 44,
137
+ 74,
138
+ 82,
139
+ 48,
140
+ 57,
141
+ 90,
142
+ 35,
143
+ 44,
144
+ 46,
145
+ 71,
146
+ 66,
147
+ 6,
148
+ 3,
149
+ 1,
150
+ 26,
151
+ 38,
152
+ 47,
153
+ 70,
154
+ 24,
155
+ 3,
156
+ 54,
157
+ 67,
158
+ 48,
159
+ 89,
160
+ 4,
161
+ 57,
162
+ 41,
163
+ 69,
164
+ 77,
165
+ 24,
166
+ 74,
167
+ 26,
168
+ 78,
169
+ 67,
170
+ 22,
171
+ 84
172
+ ],
173
+ 71
174
+ ],
175
+ "output": 9230
176
+ },
177
+ {
178
+ "input": [
179
+ [
180
+ 12,
181
+ 50,
182
+ 78,
183
+ 77,
184
+ 47,
185
+ 31,
186
+ 50,
187
+ 24,
188
+ 58,
189
+ 8,
190
+ 53,
191
+ 44,
192
+ 27,
193
+ 74,
194
+ 1,
195
+ 64,
196
+ 44,
197
+ 64,
198
+ 87,
199
+ 93,
200
+ 1,
201
+ 71,
202
+ 56,
203
+ 29,
204
+ 35,
205
+ 99,
206
+ 95,
207
+ 57,
208
+ 86,
209
+ 90,
210
+ 78,
211
+ 95,
212
+ 29,
213
+ 1,
214
+ 26,
215
+ 5,
216
+ 51,
217
+ 43,
218
+ 84,
219
+ 58,
220
+ 29,
221
+ 66,
222
+ 74,
223
+ 36,
224
+ 6,
225
+ 69,
226
+ 67,
227
+ 63,
228
+ 2,
229
+ 77,
230
+ 47,
231
+ 12,
232
+ 22,
233
+ 13,
234
+ 13,
235
+ 100,
236
+ 66,
237
+ 92,
238
+ 32,
239
+ 76,
240
+ 66,
241
+ 71,
242
+ 40,
243
+ 64,
244
+ 63,
245
+ 76,
246
+ 7,
247
+ 2,
248
+ 100,
249
+ 5,
250
+ 53,
251
+ 14,
252
+ 21,
253
+ 44,
254
+ 37,
255
+ 21,
256
+ 97,
257
+ 38,
258
+ 31,
259
+ 22
260
+ ],
261
+ 58
262
+ ],
263
+ "output": 7453
264
+ },
265
+ {
266
+ "input": [
267
+ [
268
+ 3,
269
+ 69,
270
+ 95,
271
+ 56,
272
+ 57,
273
+ 13,
274
+ 12,
275
+ 63,
276
+ 17,
277
+ 22,
278
+ 96,
279
+ 67,
280
+ 5,
281
+ 32,
282
+ 79,
283
+ 5,
284
+ 43,
285
+ 39,
286
+ 26,
287
+ 53,
288
+ 32,
289
+ 82,
290
+ 95,
291
+ 1,
292
+ 68,
293
+ 94,
294
+ 21,
295
+ 93,
296
+ 54,
297
+ 75,
298
+ 36,
299
+ 19,
300
+ 43,
301
+ 93,
302
+ 5,
303
+ 16,
304
+ 28,
305
+ 84,
306
+ 17,
307
+ 44,
308
+ 11,
309
+ 96,
310
+ 73,
311
+ 37,
312
+ 54,
313
+ 92,
314
+ 79,
315
+ 56,
316
+ 58,
317
+ 33,
318
+ 82,
319
+ 67,
320
+ 44,
321
+ 82,
322
+ 41,
323
+ 83,
324
+ 55,
325
+ 42,
326
+ 16,
327
+ 46
328
+ ],
329
+ 75
330
+ ],
331
+ "output": 9975
332
+ },
333
+ {
334
+ "input": [
335
+ [
336
+ 47,
337
+ 16,
338
+ 81,
339
+ 75,
340
+ 82,
341
+ 87,
342
+ 11,
343
+ 52,
344
+ 71,
345
+ 8,
346
+ 61,
347
+ 31,
348
+ 52,
349
+ 38,
350
+ 55,
351
+ 74,
352
+ 89,
353
+ 15,
354
+ 9,
355
+ 49,
356
+ 48,
357
+ 87,
358
+ 36,
359
+ 84,
360
+ 45,
361
+ 77,
362
+ 92,
363
+ 24,
364
+ 37,
365
+ 64,
366
+ 40,
367
+ 29,
368
+ 18,
369
+ 87,
370
+ 95,
371
+ 80,
372
+ 41,
373
+ 84,
374
+ 12,
375
+ 76,
376
+ 75,
377
+ 90,
378
+ 13,
379
+ 65,
380
+ 84
381
+ ],
382
+ 15
383
+ ],
384
+ "output": 1530
385
+ },
386
+ {
387
+ "input": [
388
+ [
389
+ 98,
390
+ 56,
391
+ 51,
392
+ 95,
393
+ 91,
394
+ 66,
395
+ 51,
396
+ 40,
397
+ 34,
398
+ 51,
399
+ 7,
400
+ 48,
401
+ 37,
402
+ 61
403
+ ],
404
+ 5
405
+ ],
406
+ "output": 500
407
+ },
408
+ {
409
+ "input": [
410
+ [
411
+ 70,
412
+ 63,
413
+ 30,
414
+ 79,
415
+ 46,
416
+ 21,
417
+ 18,
418
+ 4,
419
+ 3,
420
+ 90,
421
+ 10,
422
+ 4,
423
+ 66,
424
+ 49,
425
+ 80,
426
+ 59,
427
+ 44,
428
+ 75,
429
+ 22,
430
+ 80,
431
+ 14,
432
+ 26,
433
+ 52,
434
+ 13,
435
+ 1,
436
+ 45,
437
+ 94,
438
+ 34,
439
+ 18,
440
+ 64,
441
+ 64,
442
+ 99,
443
+ 46,
444
+ 77,
445
+ 4,
446
+ 16,
447
+ 98,
448
+ 26,
449
+ 21,
450
+ 28,
451
+ 94,
452
+ 97,
453
+ 96,
454
+ 64,
455
+ 55,
456
+ 17,
457
+ 43,
458
+ 50,
459
+ 88,
460
+ 36,
461
+ 92,
462
+ 81,
463
+ 9,
464
+ 46,
465
+ 64,
466
+ 98,
467
+ 52,
468
+ 52,
469
+ 90,
470
+ 71,
471
+ 83,
472
+ 14,
473
+ 55,
474
+ 29,
475
+ 58,
476
+ 79,
477
+ 24,
478
+ 98,
479
+ 9,
480
+ 3,
481
+ 21,
482
+ 61,
483
+ 46,
484
+ 83,
485
+ 52,
486
+ 79,
487
+ 65,
488
+ 44,
489
+ 94,
490
+ 81,
491
+ 17,
492
+ 52,
493
+ 72,
494
+ 50,
495
+ 35,
496
+ 20,
497
+ 36,
498
+ 95,
499
+ 84
500
+ ],
501
+ 75
502
+ ],
503
+ "output": 10200
504
+ },
505
+ {
506
+ "input": [
507
+ [
508
+ 93,
509
+ 89,
510
+ 46,
511
+ 52,
512
+ 63,
513
+ 18,
514
+ 87,
515
+ 33,
516
+ 74,
517
+ 49,
518
+ 27,
519
+ 50,
520
+ 69,
521
+ 41,
522
+ 78,
523
+ 5,
524
+ 17,
525
+ 74,
526
+ 58,
527
+ 37,
528
+ 77,
529
+ 25,
530
+ 56,
531
+ 7,
532
+ 83,
533
+ 43,
534
+ 54,
535
+ 65,
536
+ 96,
537
+ 51,
538
+ 52,
539
+ 29,
540
+ 14,
541
+ 85,
542
+ 15,
543
+ 66,
544
+ 20,
545
+ 71,
546
+ 82,
547
+ 31,
548
+ 24,
549
+ 33,
550
+ 49,
551
+ 95,
552
+ 14,
553
+ 6,
554
+ 18,
555
+ 63,
556
+ 28,
557
+ 91,
558
+ 87,
559
+ 62,
560
+ 56,
561
+ 57,
562
+ 81,
563
+ 72,
564
+ 2,
565
+ 21,
566
+ 70,
567
+ 41,
568
+ 37,
569
+ 45,
570
+ 10,
571
+ 81,
572
+ 74,
573
+ 10,
574
+ 83,
575
+ 16,
576
+ 93,
577
+ 53,
578
+ 88,
579
+ 32,
580
+ 100,
581
+ 20,
582
+ 63,
583
+ 100,
584
+ 20,
585
+ 21,
586
+ 36,
587
+ 27,
588
+ 34,
589
+ 14,
590
+ 62,
591
+ 9,
592
+ 44,
593
+ 82,
594
+ 64,
595
+ 54,
596
+ 69,
597
+ 49,
598
+ 10,
599
+ 89,
600
+ 82,
601
+ 15,
602
+ 99,
603
+ 18,
604
+ 46,
605
+ 51,
606
+ 71
607
+ ],
608
+ 99
609
+ ],
610
+ "output": 14751
611
+ },
612
+ {
613
+ "input": [
614
+ [
615
+ 9,
616
+ 97,
617
+ 21,
618
+ 77,
619
+ 53,
620
+ 18,
621
+ 74,
622
+ 32,
623
+ 9,
624
+ 82,
625
+ 52,
626
+ 49,
627
+ 18,
628
+ 9,
629
+ 28,
630
+ 7,
631
+ 62,
632
+ 42,
633
+ 94,
634
+ 29,
635
+ 6,
636
+ 81,
637
+ 4,
638
+ 82,
639
+ 55,
640
+ 33,
641
+ 100,
642
+ 34,
643
+ 30,
644
+ 50,
645
+ 13,
646
+ 80,
647
+ 48,
648
+ 68,
649
+ 86,
650
+ 6,
651
+ 61,
652
+ 7,
653
+ 92,
654
+ 75,
655
+ 63,
656
+ 17,
657
+ 8,
658
+ 77,
659
+ 97,
660
+ 36,
661
+ 88,
662
+ 83,
663
+ 99,
664
+ 88,
665
+ 90,
666
+ 27,
667
+ 16,
668
+ 19,
669
+ 92,
670
+ 35,
671
+ 31,
672
+ 62,
673
+ 75,
674
+ 32,
675
+ 96,
676
+ 6,
677
+ 68,
678
+ 47,
679
+ 82,
680
+ 90,
681
+ 88,
682
+ 53,
683
+ 66,
684
+ 6,
685
+ 50,
686
+ 9,
687
+ 82,
688
+ 1,
689
+ 25,
690
+ 67,
691
+ 31,
692
+ 31,
693
+ 11,
694
+ 82,
695
+ 43,
696
+ 90,
697
+ 15,
698
+ 19,
699
+ 97,
700
+ 43,
701
+ 46,
702
+ 93,
703
+ 85,
704
+ 62,
705
+ 97,
706
+ 21
707
+ ],
708
+ 8
709
+ ],
710
+ "output": 828
711
+ }
712
+ ],
713
+ "haskell_template": "maximizeSum :: [Int] -> Int -> Int\nmaximizeSum nums k ",
714
+ "ocaml_template": "let maximizeSum (nums: int list) (k: int) : int = ",
715
+ "scala_template": "def maximizeSum(nums: List[Int],k: Int): Int = { \n \n}",
716
+ "java_template": "class Solution {\n public int maximizeSum(int[] nums, int k) {\n \n }\n}",
717
+ "python_template": "class Solution(object):\n def maximizeSum(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
718
+ }
maximum_sum_with_exactly_k_elements/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 18 (maximizeSum [1;2;3;4;5] 3)
12
+
13
+ let test2 _ = assert_equal 11 (maximizeSum [5;5;5] 2)
14
+
15
+ let test3 _ = assert_equal 8580 (maximizeSum [49; 90; 3; 56; 32; 100; 38; 12; 5; 5; 90; 14; 20; 83; 97; 40; 69; 52; 50; 24; 82; 83; 2; 35; 20; 45; 36; 69; 22; 14; 35; 76; 50] 65)
16
+
17
+ let test4 _ = assert_equal 2233 (maximizeSum [44; 73; 34; 84; 91; 13; 23; 46; 6; 14; 30; 85; 75; 70; 79; 7; 60; 30; 57; 27; 59; 49] 22)
18
+
19
+ let test5 _ = assert_equal 9230 (maximizeSum [81; 14; 40; 34; 54; 23; 63; 65; 84; 84; 4; 37; 88; 41; 8; 33; 54; 18; 49; 67; 85; 37; 78; 46; 38; 80; 13; 77; 93; 5; 3; 12; 89; 36; 44; 63; 41; 22; 95; 86; 11; 44; 74; 82; 48; 57; 90; 35; 44; 46; 71; 66; 6; 3; 1; 26; 38; 47; 70; 24; 3; 54; 67; 48; 89; 4; 57; 41; 69; 77; 24; 74; 26; 78; 67; 22; 84] 71)
20
+
21
+ let test6 _ = assert_equal 7453 (maximizeSum [12; 50; 78; 77; 47; 31; 50; 24; 58; 8; 53; 44; 27; 74; 1; 64; 44; 64; 87; 93; 1; 71; 56; 29; 35; 99; 95; 57; 86; 90; 78; 95; 29; 1; 26; 5; 51; 43; 84; 58; 29; 66; 74; 36; 6; 69; 67; 63; 2; 77; 47; 12; 22; 13; 13; 100; 66; 92; 32; 76; 66; 71; 40; 64; 63; 76; 7; 2; 100; 5; 53; 14; 21; 44; 37; 21; 97; 38; 31; 22] 58)
22
+
23
+ let test7 _ = assert_equal 9975 (maximizeSum [3; 69; 95; 56; 57; 13; 12; 63; 17; 22; 96; 67; 5; 32; 79; 5; 43; 39; 26; 53; 32; 82; 95; 1; 68; 94; 21; 93; 54; 75; 36; 19; 43; 93; 5; 16; 28; 84; 17; 44; 11; 96; 73; 37; 54; 92; 79; 56; 58; 33; 82; 67; 44; 82; 41; 83; 55; 42; 16; 46] 75)
24
+
25
+ let test8 _ = assert_equal 1530 (maximizeSum [47; 16; 81; 75; 82; 87; 11; 52; 71; 8; 61; 31; 52; 38; 55; 74; 89; 15; 9; 49; 48; 87; 36; 84; 45; 77; 92; 24; 37; 64; 40; 29; 18; 87; 95; 80; 41; 84; 12; 76; 75; 90; 13; 65; 84] 15)
26
+
27
+ let test9 _ = assert_equal 500 (maximizeSum [98; 56; 51; 95; 91; 66; 51; 40; 34; 51; 7; 48; 37; 61] 5)
28
+
29
+ let test10 _ = assert_equal 10200 (maximizeSum [70; 63; 30; 79; 46; 21; 18; 4; 3; 90; 10; 4; 66; 49; 80; 59; 44; 75; 22; 80; 14; 26; 52; 13; 1; 45; 94; 34; 18; 64; 64; 99; 46; 77; 4; 16; 98; 26; 21; 28; 94; 97; 96; 64; 55; 17; 43; 50; 88; 36; 92; 81; 9; 46; 64; 98; 52; 52; 90; 71; 83; 14; 55; 29; 58; 79; 24; 98; 9; 3; 21; 61; 46; 83; 52; 79; 65; 44; 94; 81; 17; 52; 72; 50; 35; 20; 36; 95; 84] 75)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for maximizeSum" >::: [
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
maximum_sum_with_exactly_k_elements/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximizeSum(List(1,2,3,4,5),3), 18)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximizeSum(List(5,5,5),2), 11)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maximizeSum(List(49, 90, 3, 56, 32, 100, 38, 12, 5, 5, 90, 14, 20, 83, 97, 40, 69, 52, 50, 24, 82, 83, 2, 35, 20, 45, 36, 69, 22, 14, 35, 76, 50),65), 8580)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.maximizeSum(List(44, 73, 34, 84, 91, 13, 23, 46, 6, 14, 30, 85, 75, 70, 79, 7, 60, 30, 57, 27, 59, 49),22), 2233)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.maximizeSum(List(81, 14, 40, 34, 54, 23, 63, 65, 84, 84, 4, 37, 88, 41, 8, 33, 54, 18, 49, 67, 85, 37, 78, 46, 38, 80, 13, 77, 93, 5, 3, 12, 89, 36, 44, 63, 41, 22, 95, 86, 11, 44, 74, 82, 48, 57, 90, 35, 44, 46, 71, 66, 6, 3, 1, 26, 38, 47, 70, 24, 3, 54, 67, 48, 89, 4, 57, 41, 69, 77, 24, 74, 26, 78, 67, 22, 84),71), 9230)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.maximizeSum(List(12, 50, 78, 77, 47, 31, 50, 24, 58, 8, 53, 44, 27, 74, 1, 64, 44, 64, 87, 93, 1, 71, 56, 29, 35, 99, 95, 57, 86, 90, 78, 95, 29, 1, 26, 5, 51, 43, 84, 58, 29, 66, 74, 36, 6, 69, 67, 63, 2, 77, 47, 12, 22, 13, 13, 100, 66, 92, 32, 76, 66, 71, 40, 64, 63, 76, 7, 2, 100, 5, 53, 14, 21, 44, 37, 21, 97, 38, 31, 22),58), 7453)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.maximizeSum(List(3, 69, 95, 56, 57, 13, 12, 63, 17, 22, 96, 67, 5, 32, 79, 5, 43, 39, 26, 53, 32, 82, 95, 1, 68, 94, 21, 93, 54, 75, 36, 19, 43, 93, 5, 16, 28, 84, 17, 44, 11, 96, 73, 37, 54, 92, 79, 56, 58, 33, 82, 67, 44, 82, 41, 83, 55, 42, 16, 46),75), 9975)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.maximizeSum(List(47, 16, 81, 75, 82, 87, 11, 52, 71, 8, 61, 31, 52, 38, 55, 74, 89, 15, 9, 49, 48, 87, 36, 84, 45, 77, 92, 24, 37, 64, 40, 29, 18, 87, 95, 80, 41, 84, 12, 76, 75, 90, 13, 65, 84),15), 1530)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.maximizeSum(List(98, 56, 51, 95, 91, 66, 51, 40, 34, 51, 7, 48, 37, 61),5), 500)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.maximizeSum(List(70, 63, 30, 79, 46, 21, 18, 4, 3, 90, 10, 4, 66, 49, 80, 59, 44, 75, 22, 80, 14, 26, 52, 13, 1, 45, 94, 34, 18, 64, 64, 99, 46, 77, 4, 16, 98, 26, 21, 28, 94, 97, 96, 64, 55, 17, 43, 50, 88, 36, 92, 81, 9, 46, 64, 98, 52, 52, 90, 71, 83, 14, 55, 29, 58, 79, 24, 98, 9, 3, 21, 61, 46, 83, 52, 79, 65, 44, 94, 81, 17, 52, 72, 50, 35, 20, 36, 95, 84),75), 10200)
42
+ }
43
+
44
+ }
maximum_tastiness_of_candy_basket/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_tastiness_of_candy_basket/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 (maximumTastiness [13,5,1,8,21,2] 3)," 8 (maximumTastiness [13,5,1,8,21,2] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumTastiness [1,3,1] 2)," 2 (maximumTastiness [1,3,1] 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (maximumTastiness [7,7,7,7] 2)," 0 (maximumTastiness [7,7,7,7] 2))
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
maximum_tastiness_of_candy_basket/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(8, maximumTastiness(new ArrayList<>(Arrays.asList(13,5,1,8,21,2)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, maximumTastiness(new ArrayList<>(Arrays.asList(1,3,1)), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(0, maximumTastiness(new ArrayList<>(Arrays.asList(7,7,7,7)), 2));
23
+ }
24
+
25
+ }
maximum_tastiness_of_candy_basket/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1280bea03a5da8f3d87ae6e603e8c5e80697ade45396d772146b02d39ee6df76
3
+ size 12309014
maximum_tastiness_of_candy_basket/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 8 (maximumTastiness [13;5;1;8;21;2] 3)
12
+
13
+ let test2 _ = assert_equal 2 (maximumTastiness [1;3;1] 2)
14
+
15
+ let test3 _ = assert_equal 0 (maximumTastiness [7;7;7;7] 2)
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for maximumTastiness" >::: [
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
maximum_tastiness_of_candy_basket/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumTastiness(List(13,5,1,8,21,2),3), 8)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumTastiness(List(1,3,1),2), 2)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maximumTastiness(List(7,7,7,7),2), 0)
14
+ }
15
+
16
+ }