DatasetRepo commited on
Commit
383505c
·
verified ·
1 Parent(s): 6e2c15e

61a8d6905f485132fab70e578b5ea9f28927f34ecdc560da5fd03258129cca7c

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 +4 -0
  2. maximum_number_of_points_from_grid_queries/java_tests/Main.java +21 -0
  3. maximum_number_of_points_from_grid_queries/meta.json +26 -0
  4. maximum_number_of_points_from_grid_queries/ocaml_tests/main.ml +26 -0
  5. maximum_number_of_points_from_grid_queries/scala_tests/MySuite.scala +12 -0
  6. maximum_number_of_robots_within_budget/.DS_Store +0 -0
  7. maximum_number_of_robots_within_budget/haskell_tests/Main.hs +24 -0
  8. maximum_number_of_robots_within_budget/java_tests/Main.java +21 -0
  9. maximum_number_of_robots_within_budget/meta.json +749 -0
  10. maximum_number_of_robots_within_budget/ocaml_tests/main.ml +26 -0
  11. maximum_number_of_robots_within_budget/scala_tests/MySuite.scala +12 -0
  12. maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/haskell_tests/Main.hs +45 -0
  13. maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/java_tests/Main.java +21 -0
  14. maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/meta.json +97 -0
  15. maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/ocaml_tests/main.ml +50 -0
  16. maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/scala_tests/MySuite.scala +44 -0
  17. maximum_odd_binary_number/haskell_tests/Main.hs +47 -0
  18. maximum_odd_binary_number/java_tests/Main.java +20 -0
  19. maximum_odd_binary_number/meta.json +67 -0
  20. maximum_odd_binary_number/ocaml_tests/main.ml +51 -0
  21. maximum_odd_binary_number/scala_tests/MySuite.scala +44 -0
  22. maximum_or/.DS_Store +0 -0
  23. maximum_or/haskell_tests/Main.hs +24 -0
  24. maximum_or/java_tests/Main.java +21 -0
  25. maximum_or/meta.json +3 -0
  26. maximum_or/ocaml_tests/main.ml +26 -0
  27. maximum_or/scala_tests/MySuite.scala +12 -0
  28. maximum_palindromes_after_operations/haskell_tests/Main.hs +0 -0
  29. maximum_palindromes_after_operations/java_tests/Main.java +24 -0
  30. maximum_palindromes_after_operations/meta.json +0 -0
  31. maximum_palindromes_after_operations/ocaml_tests/main.ml +0 -0
  32. maximum_palindromes_after_operations/scala_tests/MySuite.scala +0 -0
  33. maximum_points_after_collecting_coins_from_all_nodes/haskell_tests/Main.hs +3 -0
  34. maximum_points_after_collecting_coins_from_all_nodes/java_tests/Main.java +21 -0
  35. maximum_points_after_collecting_coins_from_all_nodes/meta.json +3 -0
  36. maximum_points_after_collecting_coins_from_all_nodes/ocaml_tests/main.ml +0 -0
  37. maximum_points_after_collecting_coins_from_all_nodes/scala_tests/MySuite.scala +3 -0
  38. maximum_points_after_enemy_battles/java_tests/Main.java +21 -0
  39. maximum_points_in_an_archery_competition/.DS_Store +0 -0
  40. maximum_points_in_an_archery_competition/haskell_tests/Main.hs +24 -0
  41. maximum_points_in_an_archery_competition/java_tests/Main.java +21 -0
  42. maximum_points_in_an_archery_competition/meta.json +357 -0
  43. maximum_points_in_an_archery_competition/ocaml_tests/main.ml +26 -0
  44. maximum_points_in_an_archery_competition/scala_tests/MySuite.scala +12 -0
  45. maximum_points_tourist_can_earn/haskell_tests/Main.hs +0 -0
  46. maximum_points_tourist_can_earn/java_tests/Main.java +21 -0
  47. maximum_points_tourist_can_earn/meta.json +0 -0
  48. maximum_points_tourist_can_earn/ocaml_tests/main.ml +0 -0
  49. maximum_points_tourist_can_earn/scala_tests/MySuite.scala +0 -0
  50. maximum_prime_difference/haskell_tests/Main.hs +0 -0
.gitattributes CHANGED
@@ -181,3 +181,7 @@ maximum_matching_of_players_with_trainers/meta.json filter=lfs diff=lfs merge=lf
181
  maximum_number_of_groups_entering_a_competition/meta.json filter=lfs diff=lfs merge=lfs -text
182
  maximum_number_of_groups_with_increasing_length/meta.json filter=lfs diff=lfs merge=lfs -text
183
  maximum_number_of_k_divisible_components/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
181
  maximum_number_of_groups_entering_a_competition/meta.json filter=lfs diff=lfs merge=lfs -text
182
  maximum_number_of_groups_with_increasing_length/meta.json filter=lfs diff=lfs merge=lfs -text
183
  maximum_number_of_k_divisible_components/meta.json filter=lfs diff=lfs merge=lfs -text
184
+ maximum_or/meta.json filter=lfs diff=lfs merge=lfs -text
185
+ maximum_points_after_collecting_coins_from_all_nodes/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
186
+ maximum_points_after_collecting_coins_from_all_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
187
+ maximum_points_after_collecting_coins_from_all_nodes/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text
maximum_number_of_points_from_grid_queries/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(new ArrayList<>(Arrays.asList(5,8,1)), maxPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,3)),new ArrayList<>(Arrays.asList(2,5,7)),new ArrayList<>(Arrays.asList(3,5,1)))), new ArrayList<>(Arrays.asList(5,6,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0)), maxPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(5,2,1)),new ArrayList<>(Arrays.asList(1,1,2)))), new ArrayList<>(Arrays.asList(3))));
19
+ }
20
+
21
+ }
maximum_number_of_points_from_grid_queries/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2588,
3
+ "name": "maximum_number_of_points_from_grid_queries",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/maximum-number-of-points-from-grid-queries/",
6
+ "date": "1670112000000",
7
+ "task_description": "You are given an `m x n` integer matrix `grid` and an array `queries` of size `k`. Find an array `answer` of size `k` such that for each integer `queries[i]` you start in the **top left** cell of the matrix and repeat the following process: If `queries[i]` is **strictly** greater than the value of the current cell that you are in, then you get one point if it is your first time visiting this cell, and you can move to any **adjacent** cell in all `4` directions: up, down, left, and right. Otherwise, you do not get any points, and you end this process. After the process, `answer[i]` is the **maximum** number of points you can get. **Note** that for each query you are allowed to visit the same cell **multiple** times. Return _the resulting array_ `answer`. **Example 1:** ``` **Input:** grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2] **Output:** [5,8,1] **Explanation:** The diagrams above show which cells we visit to get points for each query. ``` **Example 2:** ``` **Input:** grid = [[5,2,1],[1,1,2]], queries = [3] **Output:** [0] **Explanation:** We can not get any points because the value of the top left cell is already greater than or equal to 3. ``` **Constraints:** `m == grid.length` `n == grid[i].length` `2 <= m, n <= 1000` `4 <= m * n <= 105` `k == queries.length` `1 <= k <= 104` `1 <= grid[i][j], queries[i] <= 106`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "grid = [[1,2,3],[2,5,7],[3,5,1]], queries = [5,6,2]",
12
+ "output": "[5,8,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "grid = [[5,2,1],[1,1,2]], queries = [3]",
17
+ "output": "[0] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "maxPoints :: [[Int]] -> [Int] -> [Int]\nmaxPoints grid queries ",
22
+ "ocaml_template": "let maxPoints (grid: int list list) (queries: int list) : int list = ",
23
+ "scala_template": "def maxPoints(grid: List[List[Int]],queries: List[Int]): List[Int] = { \n \n}",
24
+ "java_template": "public static List<Integer> maxPoints(List<List<Integer>> grid, List<Integer> queries) {\n\n}",
25
+ "python_template": "class Solution(object):\n def maxPoints(self, grid, queries):\n \"\"\"\n :type grid: List[List[int]]\n :type queries: List[int]\n :rtype: List[int]\n \"\"\"\n "
26
+ }
maximum_number_of_points_from_grid_queries/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal [5;8;1] (maxPoints [[1;2;3];[2;5;7];[3;5;1]] [5;6;2])
12
+
13
+ let test2 _ = assert_equal [0] (maxPoints [[5;2;1];[1;1;2]] [3])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maxPoints" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_number_of_points_from_grid_queries/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maxPoints(List(List(1,2,3),List(2,5,7),List(3,5,1)),List(5,6,2)), List(5,8,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maxPoints(List(List(5,2,1),List(1,1,2)),List(3)), List(0))
10
+ }
11
+
12
+ }
maximum_number_of_robots_within_budget/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_number_of_robots_within_budget/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 (maximumRobots [3,6,1,3,4] [2,1,3,4,5] 25)," 3 (maximumRobots [3,6,1,3,4] [2,1,3,4,5] 25))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumRobots [11,12,19] [10,8,7] 19)," 0 (maximumRobots [11,12,19] [10,8,7] 19))
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_number_of_robots_within_budget/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, maximumRobots(new ArrayList<>(Arrays.asList(3,6,1,3,4)), new ArrayList<>(Arrays.asList(2,1,3,4,5)), 25));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, maximumRobots(new ArrayList<>(Arrays.asList(11,12,19)), new ArrayList<>(Arrays.asList(10,8,7)), 19));
19
+ }
20
+
21
+ }
maximum_number_of_robots_within_budget/meta.json ADDED
@@ -0,0 +1,749 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2449,
3
+ "name": "maximum_number_of_robots_within_budget",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/maximum-number-of-robots-within-budget/",
6
+ "date": "1660953600000",
7
+ "task_description": "You have `n` robots. You are given two **0-indexed** integer arrays, `chargeTimes` and `runningCosts`, both of length `n`. The `ith` robot costs `chargeTimes[i]` units to charge and costs `runningCosts[i]` units to run. You are also given an integer `budget`. The **total cost** of running `k` chosen robots is equal to `max(chargeTimes) + k * sum(runningCosts)`, where `max(chargeTimes)` is the largest charge cost among the `k` robots and `sum(runningCosts)` is the sum of running costs among the `k` robots. Return_ the **maximum** number of **consecutive** robots you can run such that the total cost **does not** exceed _`budget`. **Example 1:** ``` **Input:** chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25 **Output:** 3 **Explanation:** It is possible to run all individual and consecutive pairs of robots within budget. To obtain answer 3, consider the first 3 robots. The total cost will be max(3,6,1) + 3 * sum(2,1,3) = 6 + 3 * 6 = 24 which is less than 25. It can be shown that it is not possible to run more than 3 consecutive robots within budget, so we return 3. ``` **Example 2:** ``` **Input:** chargeTimes = [11,12,19], runningCosts = [10,8,7], budget = 19 **Output:** 0 **Explanation:** No robot can be run that does not exceed the budget, so we return 0. ``` **Constraints:** `chargeTimes.length == runningCosts.length == n` `1 <= n <= 5 * 104` `1 <= chargeTimes[i], runningCosts[i] <= 105` `1 <= budget <= 1015`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "chargeTimes = [11,12,19], runningCosts = [10,8,7], budget = 19",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 60,
25
+ 57,
26
+ 78,
27
+ 28,
28
+ 25,
29
+ 31,
30
+ 65,
31
+ 53,
32
+ 67,
33
+ 1,
34
+ 46,
35
+ 99,
36
+ 58,
37
+ 3,
38
+ 93,
39
+ 8,
40
+ 21,
41
+ 23,
42
+ 58,
43
+ 2,
44
+ 21,
45
+ 96,
46
+ 37,
47
+ 74,
48
+ 100,
49
+ 6,
50
+ 61,
51
+ 86,
52
+ 19,
53
+ 41,
54
+ 71,
55
+ 37,
56
+ 59,
57
+ 51,
58
+ 52,
59
+ 96,
60
+ 65,
61
+ 60,
62
+ 92,
63
+ 64,
64
+ 79,
65
+ 49,
66
+ 19,
67
+ 77,
68
+ 30,
69
+ 40,
70
+ 22,
71
+ 68,
72
+ 100,
73
+ 75
74
+ ],
75
+ [
76
+ 64,
77
+ 76,
78
+ 57,
79
+ 23,
80
+ 11,
81
+ 47,
82
+ 81,
83
+ 12,
84
+ 98,
85
+ 39,
86
+ 58,
87
+ 87,
88
+ 61,
89
+ 46,
90
+ 84,
91
+ 87,
92
+ 31,
93
+ 19,
94
+ 77,
95
+ 85,
96
+ 74,
97
+ 59,
98
+ 68,
99
+ 93,
100
+ 69,
101
+ 44,
102
+ 88,
103
+ 33,
104
+ 64,
105
+ 11,
106
+ 3,
107
+ 30,
108
+ 75,
109
+ 78,
110
+ 1,
111
+ 38,
112
+ 38,
113
+ 43,
114
+ 45,
115
+ 91,
116
+ 49,
117
+ 98,
118
+ 24,
119
+ 93,
120
+ 26,
121
+ 12,
122
+ 54,
123
+ 40,
124
+ 78,
125
+ 50
126
+ ],
127
+ 210870090785272
128
+ ],
129
+ "output": 50
130
+ },
131
+ {
132
+ "input": [
133
+ [
134
+ 55,
135
+ 91,
136
+ 84,
137
+ 85,
138
+ 85,
139
+ 68,
140
+ 46,
141
+ 32,
142
+ 55,
143
+ 3,
144
+ 64,
145
+ 50,
146
+ 80,
147
+ 75,
148
+ 66,
149
+ 81,
150
+ 29
151
+ ],
152
+ [
153
+ 69,
154
+ 82,
155
+ 4,
156
+ 13,
157
+ 97,
158
+ 97,
159
+ 50,
160
+ 44,
161
+ 20,
162
+ 93,
163
+ 65,
164
+ 50,
165
+ 9,
166
+ 67,
167
+ 100,
168
+ 95,
169
+ 31
170
+ ],
171
+ 501158905863573
172
+ ],
173
+ "output": 17
174
+ },
175
+ {
176
+ "input": [
177
+ [
178
+ 68,
179
+ 14,
180
+ 1,
181
+ 56,
182
+ 93,
183
+ 41,
184
+ 32,
185
+ 30,
186
+ 24,
187
+ 22,
188
+ 67,
189
+ 70,
190
+ 76,
191
+ 74,
192
+ 43,
193
+ 55,
194
+ 36,
195
+ 78,
196
+ 33,
197
+ 53,
198
+ 50,
199
+ 87,
200
+ 91,
201
+ 40,
202
+ 37,
203
+ 94,
204
+ 92,
205
+ 75,
206
+ 4,
207
+ 90,
208
+ 61,
209
+ 22,
210
+ 96,
211
+ 42,
212
+ 58,
213
+ 63,
214
+ 68,
215
+ 96,
216
+ 6,
217
+ 21,
218
+ 28,
219
+ 71
220
+ ],
221
+ [
222
+ 85,
223
+ 28,
224
+ 34,
225
+ 85,
226
+ 10,
227
+ 20,
228
+ 100,
229
+ 80,
230
+ 89,
231
+ 82,
232
+ 65,
233
+ 3,
234
+ 39,
235
+ 13,
236
+ 44,
237
+ 90,
238
+ 64,
239
+ 10,
240
+ 96,
241
+ 73,
242
+ 88,
243
+ 60,
244
+ 70,
245
+ 72,
246
+ 46,
247
+ 86,
248
+ 11,
249
+ 63,
250
+ 64,
251
+ 44,
252
+ 83,
253
+ 25,
254
+ 92,
255
+ 83,
256
+ 12,
257
+ 36,
258
+ 33,
259
+ 8,
260
+ 18,
261
+ 84,
262
+ 54,
263
+ 74
264
+ ],
265
+ 37288282987591
266
+ ],
267
+ "output": 42
268
+ },
269
+ {
270
+ "input": [
271
+ [
272
+ 12,
273
+ 89,
274
+ 12,
275
+ 9,
276
+ 36,
277
+ 92,
278
+ 93,
279
+ 88,
280
+ 30,
281
+ 98,
282
+ 6,
283
+ 3,
284
+ 52,
285
+ 30,
286
+ 50,
287
+ 41,
288
+ 12,
289
+ 6,
290
+ 41,
291
+ 51,
292
+ 79,
293
+ 56,
294
+ 27,
295
+ 97,
296
+ 99,
297
+ 54,
298
+ 6,
299
+ 55,
300
+ 42,
301
+ 50,
302
+ 74,
303
+ 51,
304
+ 27,
305
+ 85,
306
+ 97,
307
+ 68,
308
+ 71,
309
+ 10,
310
+ 46,
311
+ 72,
312
+ 62,
313
+ 99,
314
+ 30,
315
+ 6,
316
+ 21
317
+ ],
318
+ [
319
+ 27,
320
+ 39,
321
+ 69,
322
+ 1,
323
+ 9,
324
+ 79,
325
+ 28,
326
+ 16,
327
+ 15,
328
+ 24,
329
+ 82,
330
+ 46,
331
+ 29,
332
+ 47,
333
+ 71,
334
+ 95,
335
+ 45,
336
+ 48,
337
+ 92,
338
+ 64,
339
+ 10,
340
+ 47,
341
+ 46,
342
+ 3,
343
+ 27,
344
+ 94,
345
+ 51,
346
+ 84,
347
+ 70,
348
+ 99,
349
+ 67,
350
+ 88,
351
+ 70,
352
+ 11,
353
+ 54,
354
+ 61,
355
+ 98,
356
+ 54,
357
+ 23,
358
+ 41,
359
+ 17,
360
+ 64,
361
+ 13,
362
+ 5,
363
+ 68
364
+ ],
365
+ 100631638339804
366
+ ],
367
+ "output": 45
368
+ },
369
+ {
370
+ "input": [
371
+ [
372
+ 92,
373
+ 34,
374
+ 85,
375
+ 61,
376
+ 54,
377
+ 41,
378
+ 27,
379
+ 35,
380
+ 49,
381
+ 86,
382
+ 61,
383
+ 36,
384
+ 4,
385
+ 79,
386
+ 65,
387
+ 40,
388
+ 46,
389
+ 60,
390
+ 19,
391
+ 18,
392
+ 71,
393
+ 72,
394
+ 8,
395
+ 9,
396
+ 56,
397
+ 65,
398
+ 96,
399
+ 64,
400
+ 52,
401
+ 12,
402
+ 3,
403
+ 9,
404
+ 44
405
+ ],
406
+ [
407
+ 99,
408
+ 78,
409
+ 48,
410
+ 30,
411
+ 37,
412
+ 70,
413
+ 70,
414
+ 86,
415
+ 56,
416
+ 46,
417
+ 62,
418
+ 90,
419
+ 85,
420
+ 93,
421
+ 87,
422
+ 75,
423
+ 63,
424
+ 14,
425
+ 78,
426
+ 28,
427
+ 31,
428
+ 35,
429
+ 82,
430
+ 82,
431
+ 29,
432
+ 35,
433
+ 72,
434
+ 58,
435
+ 52,
436
+ 21,
437
+ 47,
438
+ 72,
439
+ 47
440
+ ],
441
+ 424239692664293
442
+ ],
443
+ "output": 33
444
+ },
445
+ {
446
+ "input": [
447
+ [
448
+ 95,
449
+ 66,
450
+ 39,
451
+ 93,
452
+ 90,
453
+ 98,
454
+ 47,
455
+ 94,
456
+ 62,
457
+ 30,
458
+ 19,
459
+ 49,
460
+ 55,
461
+ 98,
462
+ 87,
463
+ 64,
464
+ 63,
465
+ 60,
466
+ 31,
467
+ 28,
468
+ 64,
469
+ 77,
470
+ 79,
471
+ 91,
472
+ 29,
473
+ 61,
474
+ 70,
475
+ 71,
476
+ 11,
477
+ 35,
478
+ 64,
479
+ 87,
480
+ 46,
481
+ 28,
482
+ 17,
483
+ 44
484
+ ],
485
+ [
486
+ 74,
487
+ 2,
488
+ 58,
489
+ 52,
490
+ 21,
491
+ 72,
492
+ 43,
493
+ 37,
494
+ 9,
495
+ 1,
496
+ 88,
497
+ 38,
498
+ 97,
499
+ 38,
500
+ 61,
501
+ 38,
502
+ 61,
503
+ 22,
504
+ 75,
505
+ 21,
506
+ 31,
507
+ 58,
508
+ 58,
509
+ 87,
510
+ 16,
511
+ 1,
512
+ 16,
513
+ 56,
514
+ 11,
515
+ 60,
516
+ 2,
517
+ 91,
518
+ 9,
519
+ 37,
520
+ 68,
521
+ 10
522
+ ],
523
+ 228180887669616
524
+ ],
525
+ "output": 36
526
+ },
527
+ {
528
+ "input": [
529
+ [
530
+ 23,
531
+ 73,
532
+ 21,
533
+ 71,
534
+ 55,
535
+ 59,
536
+ 9,
537
+ 78,
538
+ 50,
539
+ 58,
540
+ 30,
541
+ 10,
542
+ 75,
543
+ 65,
544
+ 82,
545
+ 24,
546
+ 23,
547
+ 43,
548
+ 58,
549
+ 100,
550
+ 65,
551
+ 86,
552
+ 10,
553
+ 86
554
+ ],
555
+ [
556
+ 81,
557
+ 63,
558
+ 54,
559
+ 22,
560
+ 22,
561
+ 1,
562
+ 32,
563
+ 26,
564
+ 73,
565
+ 59,
566
+ 21,
567
+ 57,
568
+ 6,
569
+ 52,
570
+ 25,
571
+ 75,
572
+ 38,
573
+ 37,
574
+ 8,
575
+ 98,
576
+ 39,
577
+ 52,
578
+ 50,
579
+ 33
580
+ ],
581
+ 358813912220824
582
+ ],
583
+ "output": 24
584
+ },
585
+ {
586
+ "input": [
587
+ [
588
+ 91,
589
+ 87,
590
+ 87,
591
+ 63,
592
+ 19,
593
+ 91,
594
+ 74,
595
+ 91,
596
+ 62,
597
+ 96,
598
+ 85,
599
+ 86,
600
+ 12,
601
+ 2,
602
+ 16,
603
+ 65,
604
+ 84,
605
+ 92,
606
+ 5,
607
+ 88,
608
+ 32,
609
+ 28,
610
+ 61,
611
+ 3,
612
+ 8,
613
+ 95
614
+ ],
615
+ [
616
+ 67,
617
+ 78,
618
+ 78,
619
+ 74,
620
+ 9,
621
+ 48,
622
+ 94,
623
+ 76,
624
+ 98,
625
+ 14,
626
+ 17,
627
+ 50,
628
+ 39,
629
+ 72,
630
+ 98,
631
+ 84,
632
+ 67,
633
+ 42,
634
+ 8,
635
+ 1,
636
+ 25,
637
+ 89,
638
+ 46,
639
+ 45,
640
+ 63,
641
+ 36
642
+ ],
643
+ 372085360977557
644
+ ],
645
+ "output": 26
646
+ },
647
+ {
648
+ "input": [
649
+ [
650
+ 21,
651
+ 73,
652
+ 14,
653
+ 68,
654
+ 100,
655
+ 83,
656
+ 91,
657
+ 81,
658
+ 72,
659
+ 24,
660
+ 61
661
+ ],
662
+ [
663
+ 65,
664
+ 98,
665
+ 78,
666
+ 84,
667
+ 2,
668
+ 64,
669
+ 88,
670
+ 18,
671
+ 30,
672
+ 88,
673
+ 57
674
+ ],
675
+ 275993940081086
676
+ ],
677
+ "output": 11
678
+ },
679
+ {
680
+ "input": [
681
+ [
682
+ 55,
683
+ 9,
684
+ 13,
685
+ 100,
686
+ 30,
687
+ 6,
688
+ 42,
689
+ 83,
690
+ 66,
691
+ 18,
692
+ 40,
693
+ 24,
694
+ 99,
695
+ 46,
696
+ 26,
697
+ 74,
698
+ 89,
699
+ 58,
700
+ 14,
701
+ 90,
702
+ 27,
703
+ 76,
704
+ 50,
705
+ 31,
706
+ 96,
707
+ 62,
708
+ 20
709
+ ],
710
+ [
711
+ 70,
712
+ 7,
713
+ 59,
714
+ 97,
715
+ 77,
716
+ 57,
717
+ 25,
718
+ 3,
719
+ 84,
720
+ 24,
721
+ 47,
722
+ 1,
723
+ 33,
724
+ 81,
725
+ 74,
726
+ 53,
727
+ 46,
728
+ 41,
729
+ 7,
730
+ 72,
731
+ 8,
732
+ 59,
733
+ 17,
734
+ 3,
735
+ 63,
736
+ 80,
737
+ 87
738
+ ],
739
+ 89438979818988
740
+ ],
741
+ "output": 27
742
+ }
743
+ ],
744
+ "haskell_template": "maximumRobots :: [Int] -> [Int] -> Int -> Int\nmaximumRobots chargeTimes runningCosts budget ",
745
+ "ocaml_template": "let maximumRobots (chargeTimes: int list) (runningCosts: int list) (budget: int) : int = ",
746
+ "scala_template": "def maximumRobots(chargeTimes: List[Int],runningCosts: List[Int],budget: Int): Int = { \n \n}",
747
+ "java_template": "public static int maximumRobots(List<Integer> chargeTimes, List<Integer> runningCosts, int budget) {\n\n}",
748
+ "python_template": "class Solution(object):\n def maximumRobots(self, chargeTimes, runningCosts, budget):\n \"\"\"\n :type chargeTimes: List[int]\n :type runningCosts: List[int]\n :type budget: int\n :rtype: int\n \"\"\"\n "
749
+ }
maximum_number_of_robots_within_budget/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (maximumRobots [3;6;1;3;4] [2;1;3;4;5] 25)
12
+
13
+ let test2 _ = assert_equal 0 (maximumRobots [11;12;19] [10;8;7] 19)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maximumRobots" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_number_of_robots_within_budget/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumRobots(List(3,6,1,3,4),List(2,1,3,4,5),25), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumRobots(List(11,12,19),List(10,8,7),19), 0)
10
+ }
11
+
12
+ }
maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/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 (findMaximumNumber 9 1)," 6 (findMaximumNumber 9 1))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findMaximumNumber 7 2)," 9 (findMaximumNumber 7 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (findMaximumNumber 531872414732251 7)," 177565693781781 (findMaximumNumber 531872414732251 7))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (findMaximumNumber 340835112471797 3)," 46336165184101 (findMaximumNumber 340835112471797 3))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (findMaximumNumber 160343276908028 8)," 64229223168211 (findMaximumNumber 160343276908028 8))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (findMaximumNumber 676716706602279 5)," 151604230490636 (findMaximumNumber 676716706602279 5))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (findMaximumNumber 671134782855633 8)," 231967802093764 (findMaximumNumber 671134782855633 8))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (findMaximumNumber 283099675489092 1)," 13082354738495 (findMaximumNumber 283099675489092 1))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (findMaximumNumber 844018400796959 4)," 152008536869498 (findMaximumNumber 844018400796959 4))
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_number_that_sum_of_the_prices_is_less_than_or_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(6, findMaximumNumber(9, 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(9, findMaximumNumber(7, 2));
19
+ }
20
+
21
+ }
maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3240,
3
+ "name": "maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k/",
6
+ "date": "2024-01-07 00:00:00",
7
+ "task_description": "You are given an integer `k` and an integer `x`. The price of a number `num` is calculated by the count of set bits at positions `x`, `2x`, `3x`, etc., in its binary representation, starting from the least significant bit. The following table contains examples of how price is calculated. x num Binary Representation Price 1 13 00000**1****1**0**1** 3 2 13 00000**1**101 1 2 233 0**1**1**1**0**1**001 3 3 13 000001**1**01 1 3 362 **1**01**1**01010 2 The **accumulated price** of `num` is the total price of numbers from `1` to `num`. `num` is considered **cheap** if its accumulated price is less than or equal to `k`. Return the greatest cheap number. **Example 1:** **Input:** k = 9, x = 1 **Output:** 6 **Explanation:** As shown in the table below, `6` is the greatest cheap number. x num Binary Representation Price Accumulated Price 1 1 00**1** 1 1 1 2 0**1**0 1 2 1 3 0**1****1** 2 4 1 4 **1**00 1 5 1 5 **1**0**1** 2 7 1 6 **1****1**0 2 9 1 7 **1****1****1** 3 12 **Example 2:** **Input:** k = 7, x = 2 **Output:** 9 **Explanation:** As shown in the table below, `9` is the greatest cheap number. x num Binary Representation Price Accumulated Price 2 1 0001 0 0 2 2 00**1**0 1 1 2 3 00**1**1 1 2 2 4 0100 0 2 2 5 0101 0 2 2 6 01**1**0 1 3 2 7 01**1**1 1 4 2 8 **1**000 1 5 2 9 **1**001 1 6 2 10 **1**0**1**0 2 8 **Constraints:** `1 <= k <= 1015` `1 <= x <= 8`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "k = 9, x = 1",
12
+ "output": "6 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "k = 7, x = 2",
17
+ "output": "9 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 531872414732251,
24
+ 7
25
+ ],
26
+ "output": 177565693781781
27
+ },
28
+ {
29
+ "input": [
30
+ 340835112471797,
31
+ 3
32
+ ],
33
+ "output": 46336165184101
34
+ },
35
+ {
36
+ "input": [
37
+ 160343276908028,
38
+ 8
39
+ ],
40
+ "output": 64229223168211
41
+ },
42
+ {
43
+ "input": [
44
+ 676716706602279,
45
+ 5
46
+ ],
47
+ "output": 151604230490636
48
+ },
49
+ {
50
+ "input": [
51
+ 671134782855633,
52
+ 8
53
+ ],
54
+ "output": 231967802093764
55
+ },
56
+ {
57
+ "input": [
58
+ 283099675489092,
59
+ 1
60
+ ],
61
+ "output": 13082354738495
62
+ },
63
+ {
64
+ "input": [
65
+ 844018400796959,
66
+ 4
67
+ ],
68
+ "output": 152008536869498
69
+ },
70
+ {
71
+ "input": [
72
+ 938778172153246,
73
+ 5
74
+ ],
75
+ "output": 208870257401774
76
+ },
77
+ {
78
+ "input": [
79
+ 157598202823467,
80
+ 3
81
+ ],
82
+ "output": 21909790975774
83
+ },
84
+ {
85
+ "input": [
86
+ 354416755461206,
87
+ 7
88
+ ],
89
+ "output": 118226590889092
90
+ }
91
+ ],
92
+ "haskell_template": "findMaximumNumber :: Int -> Int -> Int\nfindMaximumNumber k x ",
93
+ "ocaml_template": "let findMaximumNumber (k: int) (x: int) : int = ",
94
+ "scala_template": "def findMaximumNumber(k: Int,x: Int): Int = { \n \n}",
95
+ "java_template": "class Solution {\n public long findMaximumNumber(long k, int x) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def findMaximumNumber(self, k, x):\n \"\"\"\n :type k: int\n :type x: int\n :rtype: int\n \"\"\"\n "
97
+ }
maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/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 6 (findMaximumNumber 9 1)
12
+
13
+ let test2 _ = assert_equal 9 (findMaximumNumber 7 2)
14
+
15
+ let test3 _ = assert_equal 177565693781781 (findMaximumNumber 531872414732251 7)
16
+
17
+ let test4 _ = assert_equal 46336165184101 (findMaximumNumber 340835112471797 3)
18
+
19
+ let test5 _ = assert_equal 64229223168211 (findMaximumNumber 160343276908028 8)
20
+
21
+ let test6 _ = assert_equal 151604230490636 (findMaximumNumber 676716706602279 5)
22
+
23
+ let test7 _ = assert_equal 231967802093764 (findMaximumNumber 671134782855633 8)
24
+
25
+ let test8 _ = assert_equal 13082354738495 (findMaximumNumber 283099675489092 1)
26
+
27
+ let test9 _ = assert_equal 152008536869498 (findMaximumNumber 844018400796959 4)
28
+
29
+ let test10 _ = assert_equal 208870257401774 (findMaximumNumber 938778172153246 5)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for findMaximumNumber" >::: [
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_number_that_sum_of_the_prices_is_less_than_or_equal_to_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findMaximumNumber(9,1), 6)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findMaximumNumber(7,2), 9)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findMaximumNumber(BigInt("531872414732251"),7), BigInt("177565693781781"))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.findMaximumNumber(BigInt("340835112471797"),3), BigInt("46336165184101"))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.findMaximumNumber(BigInt("160343276908028"),8), BigInt("64229223168211"))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.findMaximumNumber(BigInt("676716706602279"),5), BigInt("151604230490636"))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.findMaximumNumber(BigInt("671134782855633"),8), BigInt("231967802093764"))
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.findMaximumNumber(BigInt("283099675489092"),1), BigInt("13082354738495"))
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.findMaximumNumber(BigInt("844018400796959"),4), BigInt("152008536869498"))
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.findMaximumNumber(BigInt("938778172153246"),5), BigInt("208870257401774"))
42
+ }
43
+
44
+ }
maximum_odd_binary_number/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ maximumOddBinaryNumber :: String -> String
7
+ maximumOddBinaryNumber s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (maximumOddBinaryNumber \"010 \")," "001" (maximumOddBinaryNumber "010"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (maximumOddBinaryNumber \"0101 \")," "1001" (maximumOddBinaryNumber "0101"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (maximumOddBinaryNumber \"100110100001001110100010000011110000001011010001110100100110000010100011110011000111010 \")," "111111111111111111111111111111111111000000000000000000000000000000000000000000000000001" (maximumOddBinaryNumber "100110100001001110100010000011110000001011010001110100100110000010100011110011000111010"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (maximumOddBinaryNumber \"0000000001100111000000111010101110111111011101010010100001101100010001111000101100100000111001 \")," "1111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000001" (maximumOddBinaryNumber "0000000001100111000000111010101110111111011101010010100001101100010001111000101100100000111001"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (maximumOddBinaryNumber \"001110000001101101100011010011110011001011101110010001000111011010110011001 \")," "111111111111111111111111111111111111100000000000000000000000000000000000001" (maximumOddBinaryNumber "001110000001101101100011010011110011001011101110010001000111011010110011001"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (maximumOddBinaryNumber \"0011010100000101010100000011101000101010000100101110101100011111010000101110110100 \")," "1111111111111111111111111111111111100000000000000000000000000000000000000000000001" (maximumOddBinaryNumber "0011010100000101010100000011101000101010000100101110101100011111010000101110110100"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (maximumOddBinaryNumber \"10111100110111000111000001111100 \")," "11111111111111111000000000000001" (maximumOddBinaryNumber "10111100110111000111000001111100"))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (maximumOddBinaryNumber \"101110000001000001011111101000100010010001101011101100011101100 \")," "111111111111111111111111111100000000000000000000000000000000001" (maximumOddBinaryNumber "101110000001000001011111101000100010010001101011101100011101100"))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (maximumOddBinaryNumber \"11101111000110011100110101101011101100101000011000001111111100000011100001 \")," "11111111111111111111111111111111111111000000000000000000000000000000000001" (maximumOddBinaryNumber "11101111000110011100110101101011101100101000011000001111111100000011100001"))
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
maximum_odd_binary_number/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("010", maximumOddBinaryNumber("010"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("0101", maximumOddBinaryNumber("0101"));
18
+ }
19
+
20
+ }
maximum_odd_binary_number/meta.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3055,
3
+ "name": "maximum_odd_binary_number",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/maximum-odd-binary-number/",
6
+ "date": "2023-09-17 00:00:00",
7
+ "task_description": "You are given a **binary** string `s` that contains at least one `'1'`. You have to **rearrange** the bits in such a way that the resulting binary number is the **maximum odd binary number** that can be created from this combination. Return _a string representing the maximum odd binary number that can be created from the given combination._ **Note **that the resulting string **can** have leading zeros. **Example 1:** ``` **Input:** s = \"010\" **Output:** \"001\" **Explanation:** Because there is just one '1', it must be in the last position. So the answer is \"001\". ``` **Example 2:** ``` **Input:** s = \"0101\" **Output:** \"1001\" **Explanation: **One of the '1's must be in the last position. The maximum number that can be made with the remaining digits is \"100\". So the answer is \"1001\". ``` **Constraints:** `1 <= s.length <= 100` `s` consists only of `'0'` and `'1'`. `s` contains at least one `'1'`.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"010\"",
12
+ "output": "\"001\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"0101\"",
17
+ "output": "\"1001\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "100110100001001110100010000011110000001011010001110100100110000010100011110011000111010",
23
+ "output": "111111111111111111111111111111111111000000000000000000000000000000000000000000000000001"
24
+ },
25
+ {
26
+ "input": "0000000001100111000000111010101110111111011101010010100001101100010001111000101100100000111001",
27
+ "output": "1111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000001"
28
+ },
29
+ {
30
+ "input": "001110000001101101100011010011110011001011101110010001000111011010110011001",
31
+ "output": "111111111111111111111111111111111111100000000000000000000000000000000000001"
32
+ },
33
+ {
34
+ "input": "0011010100000101010100000011101000101010000100101110101100011111010000101110110100",
35
+ "output": "1111111111111111111111111111111111100000000000000000000000000000000000000000000001"
36
+ },
37
+ {
38
+ "input": "10111100110111000111000001111100",
39
+ "output": "11111111111111111000000000000001"
40
+ },
41
+ {
42
+ "input": "101110000001000001011111101000100010010001101011101100011101100",
43
+ "output": "111111111111111111111111111100000000000000000000000000000000001"
44
+ },
45
+ {
46
+ "input": "11101111000110011100110101101011101100101000011000001111111100000011100001",
47
+ "output": "11111111111111111111111111111111111111000000000000000000000000000000000001"
48
+ },
49
+ {
50
+ "input": "01010100101010110010000011101111010001001110010100000111001110110",
51
+ "output": "11111111111111111111111111111100000000000000000000000000000000001"
52
+ },
53
+ {
54
+ "input": "011111110",
55
+ "output": "111111001"
56
+ },
57
+ {
58
+ "input": "111011010110101001010100001111100010101100000100110011001",
59
+ "output": "111111111111111111111111111000000000000000000000000000001"
60
+ }
61
+ ],
62
+ "haskell_template": "maximumOddBinaryNumber :: String -> String\nmaximumOddBinaryNumber s ",
63
+ "ocaml_template": "let maximumOddBinaryNumber (s: string) : string = ",
64
+ "scala_template": "def maximumOddBinaryNumber(s: String): String = { \n \n}",
65
+ "java_template": "class Solution {\n public String maximumOddBinaryNumber(String s) {\n \n }\n}",
66
+ "python_template": "class Solution(object):\n def maximumOddBinaryNumber(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
67
+ }
maximum_odd_binary_number/ocaml_tests/main.ml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let maximumOddBinaryNumber (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "001" (maximumOddBinaryNumber "010")
13
+
14
+ let test2 _ = assert_equal "1001" (maximumOddBinaryNumber "0101")
15
+
16
+ let test3 _ = assert_equal "1001" (maximumOddBinaryNumber "100110100001001110100010000011110000001011010001110100100110000010100011110011000111010")
17
+
18
+ let test4 _ = assert_equal "1001" (maximumOddBinaryNumber "0000000001100111000000111010101110111111011101010010100001101100010001111000101100100000111001")
19
+
20
+ let test5 _ = assert_equal "1001" (maximumOddBinaryNumber "001110000001101101100011010011110011001011101110010001000111011010110011001")
21
+
22
+ let test6 _ = assert_equal "1001" (maximumOddBinaryNumber "0011010100000101010100000011101000101010000100101110101100011111010000101110110100")
23
+
24
+ let test7 _ = assert_equal "1001" (maximumOddBinaryNumber "10111100110111000111000001111100")
25
+
26
+ let test8 _ = assert_equal "1001" (maximumOddBinaryNumber "101110000001000001011111101000100010010001101011101100011101100")
27
+
28
+ let test9 _ = assert_equal "1001" (maximumOddBinaryNumber "11101111000110011100110101101011101100101000011000001111111100000011100001")
29
+
30
+ let test10 _ = assert_equal "1001" (maximumOddBinaryNumber "01010100101010110010000011101111010001001110010100000111001110110")
31
+
32
+
33
+ (* Grouping test cases *)
34
+ let suite = "Test Suite for maximumOddBinaryNumber" >::: [
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
maximum_odd_binary_number/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumOddBinaryNumber("010"), "001")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumOddBinaryNumber("0101"), "1001")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.maximumOddBinaryNumber(",1,0,0,1,1,0,1,0,0,0,0,1,0,0,1,1,1,0,1,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,1,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,0,0,1,1,0,0,0,1,1,1,0,1,0,"), "111111111111111111111111111111111111000000000000000000000000000000000000000000000000001")
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.maximumOddBinaryNumber(",0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,1,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,1,0,0,1,"), "1111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000001")
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.maximumOddBinaryNumber(",0,0,1,1,1,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,0,1,1,0,1,0,0,1,1,1,1,0,0,1,1,0,0,1,0,1,1,1,0,1,1,1,0,0,1,0,0,0,1,0,0,0,1,1,1,0,1,1,0,1,0,1,1,0,0,1,1,0,0,1,"), "111111111111111111111111111111111111100000000000000000000000000000000000001")
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.maximumOddBinaryNumber(",0,0,1,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,1,1,1,0,1,0,0,0,1,0,1,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,1,0,1,1,0,0,0,1,1,1,1,1,0,1,0,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,"), "1111111111111111111111111111111111100000000000000000000000000000000000000000000001")
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.maximumOddBinaryNumber(",1,0,1,1,1,1,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,"), "11111111111111111000000000000001")
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.maximumOddBinaryNumber(",1,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,1,1,1,0,1,1,0,0,0,1,1,1,0,1,1,0,0,"), "111111111111111111111111111100000000000000000000000000000000001")
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.maximumOddBinaryNumber(",1,1,1,0,1,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,"), "11111111111111111111111111111111111111000000000000000000000000000000000001")
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.maximumOddBinaryNumber(",0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,1,1,0,0,1,0,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,0,"), "11111111111111111111111111111100000000000000000000000000000000001")
42
+ }
43
+
44
+ }
maximum_or/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_or/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 (maximumOr [12,9] 1)," 30 (maximumOr [12,9] 1))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumOr [8,1,2] 2)," 35 (maximumOr [8,1,2] 2))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
maximum_or/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, maximumOr(new ArrayList<>(Arrays.asList(12,9)), 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(35, maximumOr(new ArrayList<>(Arrays.asList(8,1,2)), 2));
19
+ }
20
+
21
+ }
maximum_or/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4a564c533529f84feb90494d1a40d61adb95e13f3b1553a65e4e6754076f61a
3
+ size 15291638
maximum_or/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 (maximumOr [12;9] 1)
12
+
13
+ let test2 _ = assert_equal 35 (maximumOr [8;1;2] 2)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maximumOr" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_or/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumOr(List(12,9),1), 30)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumOr(List(8,1,2),2), 35)
10
+ }
11
+
12
+ }
maximum_palindromes_after_operations/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
maximum_palindromes_after_operations/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(3, maxPalindromesAfterOperations(Arrays.asList("abbb","ba","aa")));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(2, maxPalindromesAfterOperations(Arrays.asList("abc","ab")));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(1, maxPalindromesAfterOperations(Arrays.asList("cd","ef","a")));
22
+ }
23
+
24
+ }
maximum_palindromes_after_operations/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
maximum_palindromes_after_operations/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
maximum_palindromes_after_operations/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
maximum_points_after_collecting_coins_from_all_nodes/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb9937282f1ac865865ea26746b243c02adaf845b132447d45f27b191702dca0
3
+ size 19218837
maximum_points_after_collecting_coins_from_all_nodes/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(11, maximumPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(2,3)))), new ArrayList<>(Arrays.asList(10,10,3,3)), 5));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(16, maximumPoints(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)))), new ArrayList<>(Arrays.asList(8,4,4)), 0));
19
+ }
20
+
21
+ }
maximum_points_after_collecting_coins_from_all_nodes/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:899599e1e5dc1356e37d21e34e915cc1791c1c163e6e25b7e95e7ad6fbdb2bd4
3
+ size 71772149
maximum_points_after_collecting_coins_from_all_nodes/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
maximum_points_after_collecting_coins_from_all_nodes/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d567bd3866fc73a251154854d1eceba6d295631637d992c0c57515e7d5e413b
3
+ size 12158982
maximum_points_after_enemy_battles/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, maximumPoints(new ArrayList<>(Arrays.asList(3,2,2)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5, maximumPoints(null, 10));
19
+ }
20
+
21
+ }
maximum_points_in_an_archery_competition/.DS_Store ADDED
Binary file (6.15 kB). View file
 
maximum_points_in_an_archery_competition/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 (maximumBobPoints 9 [1,1,0,1,0,0,2,1,0,1,2,0])," [0,0,0,0,1,1,0,0,1,2,3,1] (maximumBobPoints 9 [1,1,0,1,0,0,2,1,0,1,2,0]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (maximumBobPoints 3 [0,0,1,0,0,0,0,0,0,0,0,2])," [0,0,0,0,0,0,0,0,1,1,1,0] (maximumBobPoints 3 [0,0,1,0,0,0,0,0,0,0,0,2]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
maximum_points_in_an_archery_competition/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(new ArrayList<>(Arrays.asList(0,0,0,0,1,1,0,0,1,2,3,1)), maximumBobPoints(9, new ArrayList<>(Arrays.asList(1,1,0,1,0,0,2,1,0,1,2,0))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0,0,0,0,0,0,0,0,1,1,1,0)), maximumBobPoints(3, new ArrayList<>(Arrays.asList(0,0,1,0,0,0,0,0,0,0,0,2))));
19
+ }
20
+
21
+ }
maximum_points_in_an_archery_competition/meta.json ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2318,
3
+ "name": "maximum_points_in_an_archery_competition",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/maximum-points-in-an-archery-competition/",
6
+ "date": "1647129600000",
7
+ "task_description": "Alice and Bob are opponents in an archery competition. The competition has set the following rules: Alice first shoots `numArrows` arrows and then Bob shoots `numArrows` arrows. The points are then calculated as follows: The target has integer scoring sections ranging from `0` to `11` **inclusive**. For **each** section of the target with score `k` (in between `0` to `11`), say Alice and Bob have shot `ak` and `bk` arrows on that section respectively. If `ak >= bk`, then Alice takes `k` points. If `ak < bk`, then Bob takes `k` points. However, if `ak == bk == 0`, then **nobody** takes `k` points. For example, if Alice and Bob both shot `2` arrows on the section with score `11`, then Alice takes `11` points. On the other hand, if Alice shot `0` arrows on the section with score `11` and Bob shot `2` arrows on that same section, then Bob takes `11` points. You are given the integer `numArrows` and an integer array `aliceArrows` of size `12`, which represents the number of arrows Alice shot on each scoring section from `0` to `11`. Now, Bob wants to **maximize** the total number of points he can obtain. Return _the array _`bobArrows`_ which represents the number of arrows Bob shot on **each** scoring section from _`0`_ to _`11`. The sum of the values in `bobArrows` should equal `numArrows`. If there are multiple ways for Bob to earn the maximum total points, return **any** one of them. **Example 1:** ``` **Input:** numArrows = 9, aliceArrows = [1,1,0,1,0,0,2,1,0,1,2,0] **Output:** [0,0,0,0,1,1,0,0,1,2,3,1] **Explanation:** The table above shows how the competition is scored. Bob earns a total point of 4 + 5 + 8 + 9 + 10 + 11 = 47. It can be shown that Bob cannot obtain a score higher than 47 points. ``` **Example 2:** ``` **Input:** numArrows = 3, aliceArrows = [0,0,1,0,0,0,0,0,0,0,0,2] **Output:** [0,0,0,0,0,0,0,0,1,1,1,0] **Explanation:** The table above shows how the competition is scored. Bob earns a total point of 8 + 9 + 10 = 27. It can be shown that Bob cannot obtain a score higher than 27 points. ``` **Constraints:** `1 <= numArrows <= 105` `aliceArrows.length == bobArrows.length == 12` `0 <= aliceArrows[i], bobArrows[i] <= numArrows` `sum(aliceArrows[i]) == numArrows`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "numArrows = 9, aliceArrows = [1,1,0,1,0,0,2,1,0,1,2,0]",
12
+ "output": "[0,0,0,0,1,1,0,0,1,2,3,1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "numArrows = 3, aliceArrows = [0,0,1,0,0,0,0,0,0,0,0,2]",
17
+ "output": "[0,0,0,0,0,0,0,0,1,1,1,0] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 7327,
24
+ [
25
+ 5024,
26
+ 1281,
27
+ 875,
28
+ 79,
29
+ 22,
30
+ 6,
31
+ 30,
32
+ 5,
33
+ 3,
34
+ 0,
35
+ 0,
36
+ 2
37
+ ]
38
+ ],
39
+ "output": [
40
+ 0,
41
+ 1282,
42
+ 876,
43
+ 80,
44
+ 23,
45
+ 7,
46
+ 31,
47
+ 6,
48
+ 4,
49
+ 1,
50
+ 1,
51
+ 5016
52
+ ]
53
+ },
54
+ {
55
+ "input": [
56
+ 21169,
57
+ [
58
+ 11398,
59
+ 8048,
60
+ 894,
61
+ 239,
62
+ 173,
63
+ 284,
64
+ 78,
65
+ 28,
66
+ 5,
67
+ 21,
68
+ 0,
69
+ 1
70
+ ]
71
+ ],
72
+ "output": [
73
+ 0,
74
+ 8049,
75
+ 895,
76
+ 240,
77
+ 174,
78
+ 285,
79
+ 79,
80
+ 29,
81
+ 6,
82
+ 22,
83
+ 1,
84
+ 11389
85
+ ]
86
+ },
87
+ {
88
+ "input": [
89
+ 92215,
90
+ [
91
+ 90650,
92
+ 1305,
93
+ 215,
94
+ 2,
95
+ 38,
96
+ 4,
97
+ 1,
98
+ 0,
99
+ 0,
100
+ 0,
101
+ 0,
102
+ 0
103
+ ]
104
+ ],
105
+ "output": [
106
+ 0,
107
+ 1306,
108
+ 216,
109
+ 3,
110
+ 39,
111
+ 5,
112
+ 2,
113
+ 1,
114
+ 1,
115
+ 1,
116
+ 1,
117
+ 90640
118
+ ]
119
+ },
120
+ {
121
+ "input": [
122
+ 21066,
123
+ [
124
+ 2883,
125
+ 10299,
126
+ 1763,
127
+ 2010,
128
+ 1435,
129
+ 1608,
130
+ 572,
131
+ 93,
132
+ 119,
133
+ 153,
134
+ 71,
135
+ 60
136
+ ]
137
+ ],
138
+ "output": [
139
+ 0,
140
+ 10300,
141
+ 1764,
142
+ 2011,
143
+ 1436,
144
+ 1609,
145
+ 573,
146
+ 94,
147
+ 120,
148
+ 154,
149
+ 72,
150
+ 2933
151
+ ]
152
+ },
153
+ {
154
+ "input": [
155
+ 15410,
156
+ [
157
+ 12135,
158
+ 1876,
159
+ 1186,
160
+ 31,
161
+ 77,
162
+ 33,
163
+ 62,
164
+ 10,
165
+ 0,
166
+ 0,
167
+ 0,
168
+ 0
169
+ ]
170
+ ],
171
+ "output": [
172
+ 0,
173
+ 1877,
174
+ 1187,
175
+ 32,
176
+ 78,
177
+ 34,
178
+ 63,
179
+ 11,
180
+ 1,
181
+ 1,
182
+ 1,
183
+ 12125
184
+ ]
185
+ },
186
+ {
187
+ "input": [
188
+ 76447,
189
+ [
190
+ 69211,
191
+ 6849,
192
+ 289,
193
+ 52,
194
+ 44,
195
+ 0,
196
+ 0,
197
+ 1,
198
+ 1,
199
+ 0,
200
+ 0,
201
+ 0
202
+ ]
203
+ ],
204
+ "output": [
205
+ 0,
206
+ 6850,
207
+ 290,
208
+ 53,
209
+ 45,
210
+ 1,
211
+ 1,
212
+ 2,
213
+ 2,
214
+ 1,
215
+ 1,
216
+ 69201
217
+ ]
218
+ },
219
+ {
220
+ "input": [
221
+ 54503,
222
+ [
223
+ 16589,
224
+ 9581,
225
+ 11400,
226
+ 12064,
227
+ 1543,
228
+ 3205,
229
+ 45,
230
+ 3,
231
+ 47,
232
+ 10,
233
+ 14,
234
+ 2
235
+ ]
236
+ ],
237
+ "output": [
238
+ 0,
239
+ 9582,
240
+ 11401,
241
+ 12065,
242
+ 1544,
243
+ 3206,
244
+ 46,
245
+ 4,
246
+ 48,
247
+ 11,
248
+ 15,
249
+ 16581
250
+ ]
251
+ },
252
+ {
253
+ "input": [
254
+ 76989,
255
+ [
256
+ 1045,
257
+ 46635,
258
+ 11368,
259
+ 257,
260
+ 7394,
261
+ 1874,
262
+ 1433,
263
+ 2922,
264
+ 2958,
265
+ 1101,
266
+ 0,
267
+ 2
268
+ ]
269
+ ],
270
+ "output": [
271
+ 0,
272
+ 46636,
273
+ 11369,
274
+ 258,
275
+ 7395,
276
+ 1875,
277
+ 1434,
278
+ 2923,
279
+ 2959,
280
+ 1102,
281
+ 1,
282
+ 1037
283
+ ]
284
+ },
285
+ {
286
+ "input": [
287
+ 59368,
288
+ [
289
+ 58960,
290
+ 239,
291
+ 38,
292
+ 61,
293
+ 29,
294
+ 34,
295
+ 3,
296
+ 3,
297
+ 0,
298
+ 0,
299
+ 0,
300
+ 1
301
+ ]
302
+ ],
303
+ "output": [
304
+ 0,
305
+ 240,
306
+ 39,
307
+ 62,
308
+ 30,
309
+ 35,
310
+ 4,
311
+ 4,
312
+ 1,
313
+ 1,
314
+ 1,
315
+ 58951
316
+ ]
317
+ },
318
+ {
319
+ "input": [
320
+ 69273,
321
+ [
322
+ 59439,
323
+ 6843,
324
+ 2852,
325
+ 73,
326
+ 66,
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 0
334
+ ]
335
+ ],
336
+ "output": [
337
+ 0,
338
+ 6844,
339
+ 2853,
340
+ 74,
341
+ 67,
342
+ 1,
343
+ 1,
344
+ 1,
345
+ 1,
346
+ 1,
347
+ 1,
348
+ 59429
349
+ ]
350
+ }
351
+ ],
352
+ "haskell_template": "maximumBobPoints :: Int -> [Int] -> [Int]\nmaximumBobPoints numArrows aliceArrows ",
353
+ "ocaml_template": "let maximumBobPoints (numArrows: int) (aliceArrows: int list) : int list = ",
354
+ "scala_template": "def maximumBobPoints(numArrows: Int,aliceArrows: List[Int]): List[Int] = { \n \n}",
355
+ "java_template": "public static List<Integer> maximumBobPoints(int numArrows, List<Integer> aliceArrows) {\n\n}",
356
+ "python_template": "class Solution(object):\n def maximumBobPoints(self, numArrows, aliceArrows):\n \"\"\"\n :type numArrows: int\n :type aliceArrows: List[int]\n :rtype: List[int]\n \"\"\"\n "
357
+ }
maximum_points_in_an_archery_competition/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 [0;0;0;0;1;1;0;0;1;2;3;1] (maximumBobPoints 9 [1;1;0;1;0;0;2;1;0;1;2;0])
12
+
13
+ let test2 _ = assert_equal [0;0;0;0;0;0;0;0;1;1;1;0] (maximumBobPoints 3 [0;0;1;0;0;0;0;0;0;0;0;2])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for maximumBobPoints" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
maximum_points_in_an_archery_competition/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.maximumBobPoints(9,List(1,1,0,1,0,0,2,1,0,1,2,0)), List(0,0,0,0,1,1,0,0,1,2,3,1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.maximumBobPoints(3,List(0,0,1,0,0,0,0,0,0,0,0,2)), List(0,0,0,0,0,0,0,0,1,1,1,0))
10
+ }
11
+
12
+ }
maximum_points_tourist_can_earn/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
maximum_points_tourist_can_earn/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, maxScore(2, 1, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,3)))), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(1,0))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(8, maxScore(3, 2, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,4,2)),new ArrayList<>(Arrays.asList(2,1,2)))), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,2,1)),new ArrayList<>(Arrays.asList(2,0,4)),new ArrayList<>(Arrays.asList(3,2,0))))));
19
+ }
20
+
21
+ }
maximum_points_tourist_can_earn/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
maximum_points_tourist_can_earn/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
maximum_points_tourist_can_earn/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
maximum_prime_difference/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff