DatasetRepo commited on
Commit
00d8e40
·
verified ·
1 Parent(s): a30be03

ee6dde840dcc10881743f1bf0b2a5f4bcb7e3d5bb1904794b22863e0226926d3

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 +2 -0
  2. find_mirror_score_of_a_string/ocaml_tests/main.ml +29 -0
  3. find_mirror_score_of_a_string/scala_tests/MySuite.scala +16 -0
  4. find_missing_and_repeated_values/haskell_tests/Main.hs +26 -0
  5. find_missing_and_repeated_values/java_tests/Main.java +20 -0
  6. find_missing_and_repeated_values/meta.json +26 -0
  7. find_missing_and_repeated_values/ocaml_tests/main.ml +27 -0
  8. find_missing_and_repeated_values/scala_tests/MySuite.scala +12 -0
  9. find_number_of_coins_to_place_in_tree_nodes/haskell_tests/Main.hs +0 -0
  10. find_number_of_coins_to_place_in_tree_nodes/java_tests/Main.java +25 -0
  11. find_number_of_coins_to_place_in_tree_nodes/meta.json +3 -0
  12. find_number_of_coins_to_place_in_tree_nodes/ocaml_tests/main.ml +0 -0
  13. find_number_of_coins_to_place_in_tree_nodes/scala_tests/MySuite.scala +0 -0
  14. find_occurrences_of_an_element_in_an_array/haskell_tests/Main.hs +0 -0
  15. find_occurrences_of_an_element_in_an_array/java_tests/Main.java +21 -0
  16. find_occurrences_of_an_element_in_an_array/meta.json +3 -0
  17. find_occurrences_of_an_element_in_an_array/ocaml_tests/main.ml +0 -0
  18. find_occurrences_of_an_element_in_an_array/scala_tests/MySuite.scala +0 -0
  19. find_polygon_with_the_largest_perimeter/haskell_tests/Main.hs +0 -0
  20. find_polygon_with_the_largest_perimeter/java_tests/Main.java +24 -0
  21. find_polygon_with_the_largest_perimeter/meta.json +0 -0
  22. find_polygon_with_the_largest_perimeter/ocaml_tests/main.ml +0 -0
  23. find_polygon_with_the_largest_perimeter/scala_tests/MySuite.scala +0 -0
  24. find_products_of_elements_of_big_array/haskell_tests/Main.hs +26 -0
  25. find_products_of_elements_of_big_array/java_tests/Main.java +20 -0
  26. find_products_of_elements_of_big_array/meta.json +26 -0
  27. find_products_of_elements_of_big_array/ocaml_tests/main.ml +27 -0
  28. find_products_of_elements_of_big_array/scala_tests/MySuite.scala +12 -0
  29. find_score_of_an_array_after_marking_all_elements/.DS_Store +0 -0
  30. find_score_of_an_array_after_marking_all_elements/haskell_tests/Main.hs +24 -0
  31. find_score_of_an_array_after_marking_all_elements/java_tests/Main.java +21 -0
  32. find_score_of_an_array_after_marking_all_elements/meta.json +26 -0
  33. find_score_of_an_array_after_marking_all_elements/ocaml_tests/main.ml +26 -0
  34. find_score_of_an_array_after_marking_all_elements/scala_tests/MySuite.scala +12 -0
  35. find_special_substring_of_length_k/haskell_tests/Main.hs +45 -0
  36. find_special_substring_of_length_k/java_tests/Main.java +21 -0
  37. find_special_substring_of_length_k/meta.json +97 -0
  38. find_special_substring_of_length_k/ocaml_tests/main.ml +50 -0
  39. find_special_substring_of_length_k/scala_tests/MySuite.scala +44 -0
  40. find_subarray_with_bitwise_or_closest_to_k/haskell_tests/Main.hs +0 -0
  41. find_subarray_with_bitwise_or_closest_to_k/java_tests/Main.java +25 -0
  42. find_subarray_with_bitwise_or_closest_to_k/meta.json +0 -0
  43. find_subarray_with_bitwise_or_closest_to_k/ocaml_tests/main.ml +0 -0
  44. find_subarray_with_bitwise_or_closest_to_k/scala_tests/MySuite.scala +0 -0
  45. find_subarrays_with_equal_sum/.DS_Store +0 -0
  46. find_subarrays_with_equal_sum/haskell_tests/Main.hs +27 -0
  47. find_subarrays_with_equal_sum/java_tests/Main.java +25 -0
  48. find_subarrays_with_equal_sum/meta.json +0 -0
  49. find_subarrays_with_equal_sum/ocaml_tests/main.ml +29 -0
  50. find_subarrays_with_equal_sum/scala_tests/MySuite.scala +16 -0
.gitattributes CHANGED
@@ -118,3 +118,5 @@ find_building_where_alice_and_bob_can_meet/haskell_tests/Main.hs filter=lfs diff
118
  find_building_where_alice_and_bob_can_meet/meta.json filter=lfs diff=lfs merge=lfs -text
119
  find_closest_node_to_given_two_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
120
  find_indices_with_index_and_value_difference_ii/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
118
  find_building_where_alice_and_bob_can_meet/meta.json filter=lfs diff=lfs merge=lfs -text
119
  find_closest_node_to_given_two_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
120
  find_indices_with_index_and_value_difference_ii/meta.json filter=lfs diff=lfs merge=lfs -text
121
+ find_number_of_coins_to_place_in_tree_nodes/meta.json filter=lfs diff=lfs merge=lfs -text
122
+ find_occurrences_of_an_element_in_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
find_mirror_score_of_a_string/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 5 (calculateScore "aczzx")
12
+
13
+ let test2 _ = assert_equal 0 (calculateScore "abcdef")
14
+
15
+ let test3 _ = assert_equal 0 (calculateScore " n ")
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for calculateScore" >::: [
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
find_mirror_score_of_a_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.calculateScore("aczzx"), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.calculateScore("abcdef"), 0)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.calculateScore(",n,"), 0)
14
+ }
15
+
16
+ }
find_missing_and_repeated_values/haskell_tests/Main.hs ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ findMissingAndRepeatedValues :: [[Int]] -> [Int]
7
+ findMissingAndRepeatedValues grid = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (findMissingAndRepeatedValues [[1,3],[2,2]])," [2,4] (findMissingAndRepeatedValues [[1,3],[2,2]]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (findMissingAndRepeatedValues [[9,1,7],[8,9,2],[3,4,6]])," [9,5] (findMissingAndRepeatedValues [[9,1,7],[8,9,2],[3,4,6]]))
18
+
19
+
20
+ -- Grouping test cases
21
+ tests :: Test
22
+ tests = TestList [TestLabel "Test1" test1]
23
+
24
+ -- Running the tests
25
+ main :: IO Counts
26
+ main = runTestTT tests
find_missing_and_repeated_values/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(Arrays.asList(2,4), findMissingAndRepeatedValues(Arrays.asList(Arrays.asList(1,3),Arrays.asList(2,2))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(9,5), findMissingAndRepeatedValues(Arrays.asList(Arrays.asList(9,1,7),Arrays.asList(8,9,2),Arrays.asList(3,4,6))));
18
+ }
19
+
20
+ }
find_missing_and_repeated_values/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3227,
3
+ "name": "find_missing_and_repeated_values",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/find-missing-and-repeated-values/",
6
+ "date": "2023-12-10 00:00:00",
7
+ "task_description": "You are given a **0-indexed** 2D integer matrix `grid` of size `n * n` with values in the range `[1, n2]`. Each integer appears **exactly once** except `a` which appears **twice** and `b` which is **missing**. The task is to find the repeating and missing numbers `a` and `b`. Return _a **0-indexed **integer array _`ans`_ of size _`2`_ where _`ans[0]`_ equals to _`a`_ and _`ans[1]`_ equals to _`b`_._ **Example 1:** ``` **Input:** grid = [[1,3],[2,2]] **Output:** [2,4] **Explanation:** Number 2 is repeated and number 4 is missing so the answer is [2,4]. ``` **Example 2:** ``` **Input:** grid = [[9,1,7],[8,9,2],[3,4,6]] **Output:** [9,5] **Explanation:** Number 9 is repeated and number 5 is missing so the answer is [9,5]. ``` **Constraints:** `2 <= n == grid.length == grid[i].length <= 50` `1 <= grid[i][j] <= n * n` For all `x` that `1 <= x <= n * n` there is exactly one `x` that is not equal to any of the grid members. For all `x` that `1 <= x <= n * n` there is exactly one `x` that is equal to exactly two of the grid members. For all `x` that `1 <= x <= n * n` except two of them there is exactly one pair of `i, j` that `0 <= i, j <= n - 1` and `grid[i][j] == x`.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "grid = [[1,3],[2,2]]",
12
+ "output": "[2,4] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "grid = [[9,1,7],[8,9,2],[3,4,6]]",
17
+ "output": "[9,5] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "findMissingAndRepeatedValues :: [[Int]] -> [Int]\nfindMissingAndRepeatedValues grid ",
22
+ "ocaml_template": "let findMissingAndRepeatedValues (grid: int list list) : int list = ",
23
+ "scala_template": "def findMissingAndRepeatedValues(grid: List[List[Int]]): List[Int] = { \n \n}",
24
+ "java_template": "class Solution {\n public int[] findMissingAndRepeatedValues(int[][] grid) {\n \n }\n}",
25
+ "python_template": "class Solution(object):\n def findMissingAndRepeatedValues(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: List[int]\n \"\"\"\n "
26
+ }
find_missing_and_repeated_values/ocaml_tests/main.ml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let findMissingAndRepeatedValues (grid: int list list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [2;4] (findMissingAndRepeatedValues [[1;3];[2;2]])
13
+
14
+ let test2 _ = assert_equal [9;5] (findMissingAndRepeatedValues [[9;1;7];[8;9;2];[3;4;6]])
15
+
16
+
17
+ (* Grouping test cases *)
18
+ let suite = "Test Suite for findMissingAndRepeatedValues" >::: [
19
+
20
+ "test1" >:: test1;
21
+ "test2" >:: test2;
22
+ ]
23
+
24
+
25
+ (* Running the tests *)
26
+ let () = run_test_tt_main suite
27
+ end
find_missing_and_repeated_values/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findMissingAndRepeatedValues(List(List(1,3),List(2,2))), List(2,4))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findMissingAndRepeatedValues(List(List(9,1,7),List(8,9,2),List(3,4,6))), List(9,5))
10
+ }
11
+
12
+ }
find_number_of_coins_to_place_in_tree_nodes/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
find_number_of_coins_to_place_in_tree_nodes/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(120,1,1,1,1,1)), placedCoins(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(0,3)),new ArrayList<>(Arrays.asList(0,4)),new ArrayList<>(Arrays.asList(0,5)))), new ArrayList<>(Arrays.asList(1,2,3,4,5,6))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(280,140,32,1,1,1,1,1,1)), placedCoins(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(1,4)),new ArrayList<>(Arrays.asList(1,5)),new ArrayList<>(Arrays.asList(2,6)),new ArrayList<>(Arrays.asList(2,7)),new ArrayList<>(Arrays.asList(2,8)))), new ArrayList<>(Arrays.asList(1,4,2,3,5,7,8,-4,2))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(new ArrayList<>(Arrays.asList(0,1,1)), placedCoins(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)))), new ArrayList<>(Arrays.asList(1,2,-2))));
23
+ }
24
+
25
+ }
find_number_of_coins_to_place_in_tree_nodes/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4982a4416083e5d5b4a108e74ce233e8c20ce54505d91b64e6e0b90bc57d2846
3
+ size 15100371
find_number_of_coins_to_place_in_tree_nodes/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_number_of_coins_to_place_in_tree_nodes/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_occurrences_of_an_element_in_an_array/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
find_occurrences_of_an_element_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(0,-1,2,-1)), occurrencesOfElement(new ArrayList<>(Arrays.asList(1,3,1,7)), new ArrayList<>(Arrays.asList(1,3,2,4)), 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(-1)), occurrencesOfElement(new ArrayList<>(Arrays.asList(1,2,3)), new ArrayList<>(Arrays.asList(10)), 5));
19
+ }
20
+
21
+ }
find_occurrences_of_an_element_in_an_array/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63c2d1d4dc5c0c50201ffca8d6b40e58b7ca5863eb0f8b992ba2178ffc53b2fe
3
+ size 33307794
find_occurrences_of_an_element_in_an_array/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_occurrences_of_an_element_in_an_array/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_polygon_with_the_largest_perimeter/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
find_polygon_with_the_largest_perimeter/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(15, largestPerimeter(Arrays.asList(5,5,5)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(12, largestPerimeter(Arrays.asList(1,12,1,2,5,50,3)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(-1, largestPerimeter(Arrays.asList(5,5,50)));
22
+ }
23
+
24
+ }
find_polygon_with_the_largest_perimeter/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_polygon_with_the_largest_perimeter/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_polygon_with_the_largest_perimeter/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_products_of_elements_of_big_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ findProductsOfElements :: [[Int]] -> [Int]
7
+ findProductsOfElements queries = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (findProductsOfElements [[1,3,7]])," [4] (findProductsOfElements [[1,3,7]]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (findProductsOfElements [[2,5,3],[7,7,4]])," [2,2] (findProductsOfElements [[2,5,3],[7,7,4]]))
18
+
19
+
20
+ -- Grouping test cases
21
+ tests :: Test
22
+ tests = TestList [TestLabel "Test1" test1]
23
+
24
+ -- Running the tests
25
+ main :: IO Counts
26
+ main = runTestTT tests
find_products_of_elements_of_big_array/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(Arrays.asList(4), findProductsOfElements(Arrays.asList(Arrays.asList(1,3,7))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(2,2), findProductsOfElements(Arrays.asList(Arrays.asList(2,5,3),Arrays.asList(7,7,4))));
18
+ }
19
+
20
+ }
find_products_of_elements_of_big_array/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3411,
3
+ "name": "find_products_of_elements_of_big_array",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/find-products-of-elements-of-big-array/",
6
+ "date": "2024-04-27 00:00:00",
7
+ "task_description": "The **powerful array** of a non-negative integer `x` is defined as the shortest sorted array of powers of two that sum up to `x`. The table below illustrates examples of how the **powerful array** is determined. It can be proven that the powerful array of `x` is unique. num Binary Representation powerful array 1 00001 [1] 8 01000 [8] 10 01010 [2, 8] 13 01101 [1, 4, 8] 23 10111 [1, 2, 4, 16] The array `big_nums` is created by concatenating the **powerful arrays** for every positive integer `i` in ascending order: 1, 2, 3, and so on. Thus, `big_nums` begins as `[1, 2, 1, 2, 4, 1, 4, 2, 4, 1, 2, 4, 8, ...]`. You are given a 2D integer matrix `queries`, where for `queries[i] = [fromi, toi, modi]` you should calculate `(big_nums[fromi] * big_nums[fromi + 1] * ... * big_nums[toi]) % modi`. Return an integer array `answer` such that `answer[i]` is the answer to the `ith` query. **Example 1:** **Input:** queries = [[1,3,7]] **Output:** [4] **Explanation:** There is one query. `big_nums[1..3] = [2,1,2]`. The product of them is 4. The result is `4 % 7 = 4.` **Example 2:** **Input:** queries = [[2,5,3],[7,7,4]] **Output:** [2,2] **Explanation:** There are two queries. First query: `big_nums[2..5] = [1,2,4,1]`. The product of them is 8. The result is `8 % 3 = 2`. Second query: `big_nums[7] = 2`. The result is `2 % 4 = 2`. **Constraints:** `1 <= queries.length <= 500` `queries[i].length == 3` `0 <= queries[i][0] <= queries[i][1] <= 1015` `1 <= queries[i][2] <= 105`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "queries = [[1,3,7]]",
12
+ "output": "[4] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "queries = [[2,5,3],[7,7,4]]",
17
+ "output": "[2,2] "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "findProductsOfElements :: [[Int]] -> [Int]\nfindProductsOfElements queries ",
22
+ "ocaml_template": "let findProductsOfElements (queries: int list list) : int list = ",
23
+ "scala_template": "def findProductsOfElements(queries: List[List[Int]]): List[Int] = { \n \n}",
24
+ "java_template": "class Solution {\n public int[] findProductsOfElements(long[][] queries) {\n \n }\n}",
25
+ "python_template": "class Solution(object):\n def findProductsOfElements(self, queries):\n \"\"\"\n :type queries: List[List[int]]\n :rtype: List[int]\n \"\"\"\n "
26
+ }
find_products_of_elements_of_big_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let findProductsOfElements (queries: int list list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [4] (findProductsOfElements [[1;3;7]])
13
+
14
+ let test2 _ = assert_equal [2;2] (findProductsOfElements [[2;5;3];[7;7;4]])
15
+
16
+
17
+ (* Grouping test cases *)
18
+ let suite = "Test Suite for findProductsOfElements" >::: [
19
+
20
+ "test1" >:: test1;
21
+ "test2" >:: test2;
22
+ ]
23
+
24
+
25
+ (* Running the tests *)
26
+ let () = run_test_tt_main suite
27
+ end
find_products_of_elements_of_big_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findProductsOfElements(List(List(1,3,7))), List(4))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findProductsOfElements(List(List(2,5,3),List(7,7,4))), List(2,2))
10
+ }
11
+
12
+ }
find_score_of_an_array_after_marking_all_elements/.DS_Store ADDED
Binary file (6.15 kB). View file
 
find_score_of_an_array_after_marking_all_elements/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 (findScore [2,1,3,4,5,2])," 7 (findScore [2,1,3,4,5,2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findScore [2,3,5,1,3,2])," 5 (findScore [2,3,5,1,3,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
find_score_of_an_array_after_marking_all_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, findScore(new ArrayList<>(Arrays.asList(2,1,3,4,5,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5, findScore(new ArrayList<>(Arrays.asList(2,3,5,1,3,2))));
19
+ }
20
+
21
+ }
find_score_of_an_array_after_marking_all_elements/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2695,
3
+ "name": "find_score_of_an_array_after_marking_all_elements",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/find-score-of-an-array-after-marking-all-elements/",
6
+ "date": "1677888000000",
7
+ "task_description": "You are given an array `nums` consisting of positive integers. Starting with `score = 0`, apply the following algorithm: Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index. Add the value of the chosen integer to `score`. Mark **the chosen element and its two adjacent elements if they exist**. Repeat until all the array elements are marked. Return _the score you get after applying the above algorithm_. **Example 1:** ``` **Input:** nums = [2,1,3,4,5,2] **Output:** 7 **Explanation:** We mark the elements as follows: - 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,1,3,4,5,2]. - 2 is the smallest unmarked element, so we mark it and its left adjacent element: [2,1,3,4,5,2]. - 4 is the only remaining unmarked element, so we mark it: [2,1,3,4,5,2]. Our score is 1 + 2 + 4 = 7. ``` **Example 2:** ``` **Input:** nums = [2,3,5,1,3,2] **Output:** 5 **Explanation:** We mark the elements as follows: - 1 is the smallest unmarked element, so we mark it and its two adjacent elements: [2,3,5,1,3,2]. - 2 is the smallest unmarked element, since there are two of them, we choose the left-most one, so we mark the one at index 0 and its right adjacent element: [2,3,5,1,3,2]. - 2 is the only remaining unmarked element, so we mark it: [2,3,5,1,3,2]. Our score is 1 + 2 + 2 = 5. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 106`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [2,1,3,4,5,2]",
12
+ "output": "7 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [2,3,5,1,3,2]",
17
+ "output": "5 "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "findScore :: [Int] -> Int\nfindScore nums ",
22
+ "ocaml_template": "let findScore (nums: int list) : int = ",
23
+ "scala_template": "def findScore(nums: List[Int]): Int = { \n \n}",
24
+ "java_template": "public static int findScore(List<Integer> nums) {\n\n}",
25
+ "python_template": "class Solution(object):\n def findScore(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
26
+ }
find_score_of_an_array_after_marking_all_elements/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 7 (findScore [2;1;3;4;5;2])
12
+
13
+ let test2 _ = assert_equal 5 (findScore [2;3;5;1;3;2])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for findScore" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
find_score_of_an_array_after_marking_all_elements/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findScore(List(2,1,3,4,5,2)), 7)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findScore(List(2,3,5,1,3,2)), 5)
10
+ }
11
+
12
+ }
find_special_substring_of_length_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 (hasSpecialSubstring \"aaabaaa \" 3)," True (hasSpecialSubstring "aaabaaa" 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (hasSpecialSubstring \"abc \" 2)," False (hasSpecialSubstring "abc" 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (hasSpecialSubstring \"npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg \" 8)," False (hasSpecialSubstring "npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg" 8))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (hasSpecialSubstring \"frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee \" 53)," False (hasSpecialSubstring "frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee" 53))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (hasSpecialSubstring \"ow \" 2)," False (hasSpecialSubstring "ow" 2))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (hasSpecialSubstring \"kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz \" 10)," False (hasSpecialSubstring "kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz" 10))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (hasSpecialSubstring \"puvexiblpdkdberrcjucrehjrzizyobtittk \" 15)," False (hasSpecialSubstring "puvexiblpdkdberrcjucrehjrzizyobtittk" 15))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (hasSpecialSubstring \"nbmzvrvoljbqwtwmj \" 1)," True (hasSpecialSubstring "nbmzvrvoljbqwtwmj" 1))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (hasSpecialSubstring \"laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco \" 61)," False (hasSpecialSubstring "laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco" 61))
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
find_special_substring_of_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(true, hasSpecialSubstring("aaabaaa", 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, hasSpecialSubstring("abc", 2));
19
+ }
20
+
21
+ }
find_special_substring_of_length_k/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3709,
3
+ "name": "find_special_substring_of_length_k",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/find-special-substring-of-length-k/",
6
+ "date": "2025-02-09 00:00:00",
7
+ "task_description": "You are given a string `s` and an integer `k`. Determine if there exists a substring of length **exactly** `k` in `s` that satisfies the following conditions: The substring consists of **only one distinct character** (e.g., `\"aaa\"` or `\"bbb\"`). If there is a character **immediately before** the substring, it must be different from the character in the substring. If there is a character **immediately after** the substring, it must also be different from the character in the substring. Return `true` if such a substring exists. Otherwise, return `false`. **Example 1:** **Input:** s = \"aaabaaa\", k = 3 **Output:** true **Explanation:** The substring `s[4..6] == \"aaa\"` satisfies the conditions. It has a length of 3. All characters are the same. The character before `\"aaa\"` is `'b'`, which is different from `'a'`. There is no character after `\"aaa\"`. **Example 2:** **Input:** s = \"abc\", k = 2 **Output:** false **Explanation:** There is no substring of length 2 that consists of one distinct character and satisfies the conditions. **Constraints:** `1 <= k <= s.length <= 100` `s` consists of lowercase English letters only.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"aaabaaa\", k = 3",
12
+ "output": "true "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"abc\", k = 2",
17
+ "output": "false "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg\"",
24
+ 8
25
+ ],
26
+ "output": false
27
+ },
28
+ {
29
+ "input": [
30
+ "\"frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee\"",
31
+ 53
32
+ ],
33
+ "output": false
34
+ },
35
+ {
36
+ "input": [
37
+ "\"ow\"",
38
+ 2
39
+ ],
40
+ "output": false
41
+ },
42
+ {
43
+ "input": [
44
+ "\"kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz\"",
45
+ 10
46
+ ],
47
+ "output": false
48
+ },
49
+ {
50
+ "input": [
51
+ "\"puvexiblpdkdberrcjucrehjrzizyobtittk\"",
52
+ 15
53
+ ],
54
+ "output": false
55
+ },
56
+ {
57
+ "input": [
58
+ "\"nbmzvrvoljbqwtwmj\"",
59
+ 1
60
+ ],
61
+ "output": true
62
+ },
63
+ {
64
+ "input": [
65
+ "\"laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco\"",
66
+ 61
67
+ ],
68
+ "output": false
69
+ },
70
+ {
71
+ "input": [
72
+ "\"wohlljnaddwmpuwamgkiyfvtuzbpcjhlvohkrwnpaiolofylskymmeouuoztkpqbcxjuxqpkqhgjmuutdxdjmjdkwkamikp\"",
73
+ 32
74
+ ],
75
+ "output": false
76
+ },
77
+ {
78
+ "input": [
79
+ "vzlfovuxlagnyfozvkgmnjtvgvrpfrdxvljppyqmgaclfmeyezxuzlkplyodjppbszuffvacllvhrhtxajwokdyov",
80
+ 7
81
+ ],
82
+ "output": false
83
+ },
84
+ {
85
+ "input": [
86
+ "dgjbknmicwjojjbtmhtbfqlkssfvcmxnxvqagiwbuhjkikhxkqevbegxzwanhzulrxvve",
87
+ 64
88
+ ],
89
+ "output": false
90
+ }
91
+ ],
92
+ "haskell_template": "hasSpecialSubstring :: String -> Int -> Bool\nhasSpecialSubstring s k ",
93
+ "ocaml_template": "let hasSpecialSubstring (s: string) (k: int) : bool = ",
94
+ "scala_template": "def hasSpecialSubstring(s: String,k: Int): Boolean = { \n \n}",
95
+ "java_template": "class Solution {\n public boolean hasSpecialSubstring(String s, int k) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def hasSpecialSubstring(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: bool\n \"\"\"\n "
97
+ }
find_special_substring_of_length_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 true (hasSpecialSubstring "aaabaaa" 3)
12
+
13
+ let test2 _ = assert_equal false (hasSpecialSubstring "abc" 2)
14
+
15
+ let test3 _ = assert_equal false (hasSpecialSubstring "npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg" 8)
16
+
17
+ let test4 _ = assert_equal false (hasSpecialSubstring "frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee" 53)
18
+
19
+ let test5 _ = assert_equal false (hasSpecialSubstring "ow" 2)
20
+
21
+ let test6 _ = assert_equal false (hasSpecialSubstring "kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz" 10)
22
+
23
+ let test7 _ = assert_equal false (hasSpecialSubstring "puvexiblpdkdberrcjucrehjrzizyobtittk" 15)
24
+
25
+ let test8 _ = assert_equal true (hasSpecialSubstring "nbmzvrvoljbqwtwmj" 1)
26
+
27
+ let test9 _ = assert_equal false (hasSpecialSubstring "laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco" 61)
28
+
29
+ let test10 _ = assert_equal false (hasSpecialSubstring "wohlljnaddwmpuwamgkiyfvtuzbpcjhlvohkrwnpaiolofylskymmeouuoztkpqbcxjuxqpkqhgjmuutdxdjmjdkwkamikp" 32)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for hasSpecialSubstring" >::: [
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
find_special_substring_of_length_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.hasSpecialSubstring("aaabaaa",3), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.hasSpecialSubstring("abc",2), false)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.hasSpecialSubstring("npiqeyedtwkxpacknwmuiqjwfcjoaspqjjrkedlpsecmlbdzjhmmadyuffboureyfg",8), false)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.hasSpecialSubstring("frfibfvbjbembzqmpygdsutmdnefweotbbutvihqaodnvkhlovtyhvgksijkrvqclikuzdgjee",53), false)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.hasSpecialSubstring("ow",2), false)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.hasSpecialSubstring("kcbgeeldqbijcfbfwkxjtzrrgvcplhftpaz",10), false)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.hasSpecialSubstring("puvexiblpdkdberrcjucrehjrzizyobtittk",15), false)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.hasSpecialSubstring("nbmzvrvoljbqwtwmj",1), true)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.hasSpecialSubstring("laluchhncipksfyucufozhrkflsrbeqkrnrvyiaihwkptuiquycoxfpmelchzdciilupqsdaqkkyjnkzdyejhatdzjdcco",61), false)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.hasSpecialSubstring("wohlljnaddwmpuwamgkiyfvtuzbpcjhlvohkrwnpaiolofylskymmeouuoztkpqbcxjuxqpkqhgjmuutdxdjmjdkwkamikp",32), false)
42
+ }
43
+
44
+ }
find_subarray_with_bitwise_or_closest_to_k/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
find_subarray_with_bitwise_or_closest_to_k/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(0, minimumDifference(new ArrayList<>(Arrays.asList(1,2,4,5)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, minimumDifference(new ArrayList<>(Arrays.asList(1,3,1,3)), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(9, minimumDifference(new ArrayList<>(Arrays.asList(1)), 10));
23
+ }
24
+
25
+ }
find_subarray_with_bitwise_or_closest_to_k/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_subarray_with_bitwise_or_closest_to_k/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_subarray_with_bitwise_or_closest_to_k/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_subarrays_with_equal_sum/.DS_Store ADDED
Binary file (6.15 kB). View file
 
find_subarrays_with_equal_sum/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 (findSubarrays [4,2,4])," True (findSubarrays [4,2,4]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findSubarrays [1,2,3,4,5])," False (findSubarrays [1,2,3,4,5]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (findSubarrays [0,0,0])," True (findSubarrays [0,0,0]))
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
find_subarrays_with_equal_sum/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(true, findSubarrays(new ArrayList<>(Arrays.asList(4,2,4))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(false, findSubarrays(new ArrayList<>(Arrays.asList(1,2,3,4,5))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(true, findSubarrays(new ArrayList<>(Arrays.asList(0,0,0))));
23
+ }
24
+
25
+ }
find_subarrays_with_equal_sum/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_subarrays_with_equal_sum/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 true (findSubarrays [4;2;4])
12
+
13
+ let test2 _ = assert_equal false (findSubarrays [1;2;3;4;5])
14
+
15
+ let test3 _ = assert_equal true (findSubarrays [0;0;0])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for findSubarrays" >::: [
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
find_subarrays_with_equal_sum/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findSubarrays(List(4,2,4)), true)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findSubarrays(List(1,2,3,4,5)), false)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findSubarrays(List(0,0,0)), true)
14
+ }
15
+
16
+ }