DatasetRepo commited on
Commit
d51917b
·
verified ·
1 Parent(s): 5964563

35196a8d623a29fd9d0888b07d48d576846cf1a68fff0b2b570d1f3187eec310

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_the_value_of_the_partition/java_tests/Main.java +20 -0
  3. find_the_value_of_the_partition/meta.json +0 -0
  4. find_the_value_of_the_partition/ocaml_tests/main.ml +0 -0
  5. find_the_value_of_the_partition/scala_tests/MySuite.scala +0 -0
  6. find_the_width_of_columns_of_a_grid/.DS_Store +0 -0
  7. find_the_width_of_columns_of_a_grid/haskell_tests/Main.hs +24 -0
  8. find_the_width_of_columns_of_a_grid/java_tests/Main.java +21 -0
  9. find_the_width_of_columns_of_a_grid/meta.json +0 -0
  10. find_the_width_of_columns_of_a_grid/ocaml_tests/main.ml +26 -0
  11. find_the_width_of_columns_of_a_grid/scala_tests/MySuite.scala +12 -0
  12. find_the_xor_of_numbers_which_appear_twice/haskell_tests/Main.hs +44 -0
  13. find_the_xor_of_numbers_which_appear_twice/java_tests/Main.java +24 -0
  14. find_the_xor_of_numbers_which_appear_twice/meta.json +120 -0
  15. find_the_xor_of_numbers_which_appear_twice/ocaml_tests/main.ml +45 -0
  16. find_the_xor_of_numbers_which_appear_twice/scala_tests/MySuite.scala +36 -0
  17. find_triangular_sum_of_an_array/.DS_Store +0 -0
  18. find_triangular_sum_of_an_array/haskell_tests/Main.hs +24 -0
  19. find_triangular_sum_of_an_array/java_tests/Main.java +21 -0
  20. find_triangular_sum_of_an_array/meta.json +0 -0
  21. find_triangular_sum_of_an_array/ocaml_tests/main.ml +26 -0
  22. find_triangular_sum_of_an_array/scala_tests/MySuite.scala +12 -0
  23. find_valid_pair_of_adjacent_digits_in_string/haskell_tests/Main.hs +44 -0
  24. find_valid_pair_of_adjacent_digits_in_string/java_tests/Main.java +24 -0
  25. find_valid_pair_of_adjacent_digits_in_string/meta.json +52 -0
  26. find_valid_pair_of_adjacent_digits_in_string/ocaml_tests/main.ml +45 -0
  27. find_valid_pair_of_adjacent_digits_in_string/scala_tests/MySuite.scala +16 -0
  28. find_words_containing_character/java_tests/Main.java +25 -0
  29. find_x_sum_of_all_k_long_subarrays_i/haskell_tests/Main.hs +45 -0
  30. find_x_sum_of_all_k_long_subarrays_i/java_tests/Main.java +21 -0
  31. find_x_sum_of_all_k_long_subarrays_i/meta.json +338 -0
  32. find_x_sum_of_all_k_long_subarrays_i/ocaml_tests/main.ml +50 -0
  33. find_x_sum_of_all_k_long_subarrays_i/scala_tests/MySuite.scala +44 -0
  34. find_x_sum_of_all_k_long_subarrays_ii/haskell_tests/Main.hs +3 -0
  35. find_x_sum_of_all_k_long_subarrays_ii/java_tests/Main.java +21 -0
  36. find_x_sum_of_all_k_long_subarrays_ii/meta.json +3 -0
  37. find_x_sum_of_all_k_long_subarrays_ii/ocaml_tests/main.ml +0 -0
  38. find_x_sum_of_all_k_long_subarrays_ii/scala_tests/MySuite.scala +0 -0
  39. find_xor_beauty_of_array/haskell_tests/Main.hs +0 -0
  40. find_xor_beauty_of_array/java_tests/Main.java +20 -0
  41. find_xor_beauty_of_array/meta.json +0 -0
  42. find_xor_beauty_of_array/ocaml_tests/main.ml +0 -0
  43. find_xor_beauty_of_array/scala_tests/MySuite.scala +0 -0
  44. first_completely_painted_row_or_column/.DS_Store +0 -0
  45. first_completely_painted_row_or_column/haskell_tests/Main.hs +24 -0
  46. first_completely_painted_row_or_column/java_tests/Main.java +21 -0
  47. first_completely_painted_row_or_column/meta.json +1089 -0
  48. first_completely_painted_row_or_column/ocaml_tests/main.ml +26 -0
  49. first_completely_painted_row_or_column/scala_tests/MySuite.scala +12 -0
  50. first_letter_to_appear_twice/.DS_Store +0 -0
.gitattributes CHANGED
@@ -129,3 +129,5 @@ find_the_minimum_area_to_cover_all_ones_i/meta.json filter=lfs diff=lfs merge=lf
129
  find_the_number_of_good_pairs_ii/meta.json filter=lfs diff=lfs merge=lfs -text
130
  find_the_original_array_of_prefix_xor/meta.json filter=lfs diff=lfs merge=lfs -text
131
  find_the_score_of_all_prefixes_of_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
129
  find_the_number_of_good_pairs_ii/meta.json filter=lfs diff=lfs merge=lfs -text
130
  find_the_original_array_of_prefix_xor/meta.json filter=lfs diff=lfs merge=lfs -text
131
  find_the_score_of_all_prefixes_of_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
132
+ find_x_sum_of_all_k_long_subarrays_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
133
+ find_x_sum_of_all_k_long_subarrays_ii/meta.json filter=lfs diff=lfs merge=lfs -text
find_the_value_of_the_partition/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(1, findValueOfPartition(Arrays.asList(1,3,2,4)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(9, findValueOfPartition(Arrays.asList(100,1,10)));
18
+ }
19
+
20
+ }
find_the_value_of_the_partition/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_the_value_of_the_partition/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_the_value_of_the_partition/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_the_width_of_columns_of_a_grid/.DS_Store ADDED
Binary file (6.15 kB). View file
 
find_the_width_of_columns_of_a_grid/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 (findColumnWidth [[1],[22],[333]])," [3] (findColumnWidth [[1],[22],[333]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findColumnWidth [[-15,1,3],[15,7,12],[5,6,-2]])," [3,1,2] (findColumnWidth [[-15,1,3],[15,7,12],[5,6,-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_the_width_of_columns_of_a_grid/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(3)), findColumnWidth(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1)),new ArrayList<>(Arrays.asList(22)),new ArrayList<>(Arrays.asList(333))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(3,1,2)), findColumnWidth(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(-15,1,3)),new ArrayList<>(Arrays.asList(15,7,12)),new ArrayList<>(Arrays.asList(5,6,-2))))));
19
+ }
20
+
21
+ }
find_the_width_of_columns_of_a_grid/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_the_width_of_columns_of_a_grid/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] (findColumnWidth [[1];[22];[333]])
12
+
13
+ let test2 _ = assert_equal [3;1;2] (findColumnWidth [[-15;1;3];[15;7;12];[5;6;-2]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for findColumnWidth" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
find_the_width_of_columns_of_a_grid/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findColumnWidth(List(List(1),List(22),List(333))), List(3))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findColumnWidth(List(List(-15,1,3),List(15,7,12),List(5,6,-2))), List(3,1,2))
10
+ }
11
+
12
+ }
find_the_xor_of_numbers_which_appear_twice/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ duplicateNumbersXOR :: [Int] -> Int
7
+ duplicateNumbersXOR nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (duplicateNumbersXOR [1,2,1,3])," 1 (duplicateNumbersXOR [1,2,1,3]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (duplicateNumbersXOR [1,2,3])," 0 (duplicateNumbersXOR [1,2,3]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (duplicateNumbersXOR [1,2,2,1])," 3 (duplicateNumbersXOR [1,2,2,1]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (duplicateNumbersXOR [13, 13, 31, 31, 31, 1, 38, 38, 49, 10, 10, 20, 20, 45, 45, 13])," 21 (duplicateNumbersXOR [13, 13, 31, 31, 31, 1, 38, 38, 49, 10, 10, 20, 20, 45, 45, 13]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (duplicateNumbersXOR [38, 15, 15, 44, 19, 44, 35, 35, 31, 6, 6, 33, 34, 16, 16, 36, 36, 47, 20])," 50 (duplicateNumbersXOR [38, 15, 15, 44, 19, 44, 35, 35, 31, 6, 6, 33, 34, 16, 16, 36, 36, 47, 20]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (duplicateNumbersXOR [23, 27, 27, 3, 21])," 27 (duplicateNumbersXOR [23, 27, 27, 3, 21]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (duplicateNumbersXOR [10, 32, 21, 21, 3, 3, 13, 24, 24, 10, 21, 18, 44, 44, 16])," 61 (duplicateNumbersXOR [10, 32, 21, 21, 3, 3, 13, 24, 24, 10, 21, 18, 44, 44, 16]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (duplicateNumbersXOR [19, 19, 36, 42, 42, 1, 24, 24])," 33 (duplicateNumbersXOR [19, 19, 36, 42, 42, 1, 24, 24]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
find_the_xor_of_numbers_which_appear_twice/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(1, duplicateNumbersXOR(Arrays.asList(1,2,1,3)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(0, duplicateNumbersXOR(Arrays.asList(1,2,3)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(3, duplicateNumbersXOR(Arrays.asList(1,2,2,1)));
22
+ }
23
+
24
+ }
find_the_xor_of_numbers_which_appear_twice/meta.json ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3428,
3
+ "name": "find_the_xor_of_numbers_which_appear_twice",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/find-the-xor-of-numbers-which-appear-twice/",
6
+ "date": "2024-05-11 00:00:00",
7
+ "task_description": "You are given an array `nums`, where each number in the array appears **either**_ _once_ _or_ _twice. Return the bitwise_ _`XOR` of all the numbers that appear twice in the array, or 0 if no number appears twice. **Example 1:** **Input:** nums = [1,2,1,3] **Output:** 1 **Explanation:** The only number that appears twice in `nums` is 1. **Example 2:** **Input:** nums = [1,2,3] **Output:** 0 **Explanation:** No number appears twice in `nums`. **Example 3:** **Input:** nums = [1,2,2,1] **Output:** 3 **Explanation:** Numbers 1 and 2 appeared twice. `1 XOR 2 == 3`. **Constraints:** `1 <= nums.length <= 50` `1 <= nums[i] <= 50` Each number in `nums` appears either once or twice.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,1,3]",
12
+ "output": "1 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,2,3]",
17
+ "output": "0 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [1,2,2,1]",
22
+ "output": "3 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 13,
29
+ 13,
30
+ 31,
31
+ 31,
32
+ 31,
33
+ 1,
34
+ 38,
35
+ 38,
36
+ 49,
37
+ 10,
38
+ 10,
39
+ 20,
40
+ 20,
41
+ 45,
42
+ 45,
43
+ 13
44
+ ],
45
+ "output": 21
46
+ },
47
+ {
48
+ "input": [
49
+ 38,
50
+ 15,
51
+ 15,
52
+ 44,
53
+ 19,
54
+ 44,
55
+ 35,
56
+ 35,
57
+ 31,
58
+ 6,
59
+ 6,
60
+ 33,
61
+ 34,
62
+ 16,
63
+ 16,
64
+ 36,
65
+ 36,
66
+ 47,
67
+ 20
68
+ ],
69
+ "output": 50
70
+ },
71
+ {
72
+ "input": [
73
+ 23,
74
+ 27,
75
+ 27,
76
+ 3,
77
+ 21
78
+ ],
79
+ "output": 27
80
+ },
81
+ {
82
+ "input": [
83
+ 10,
84
+ 32,
85
+ 21,
86
+ 21,
87
+ 3,
88
+ 3,
89
+ 13,
90
+ 24,
91
+ 24,
92
+ 10,
93
+ 21,
94
+ 18,
95
+ 44,
96
+ 44,
97
+ 16
98
+ ],
99
+ "output": 61
100
+ },
101
+ {
102
+ "input": [
103
+ 19,
104
+ 19,
105
+ 36,
106
+ 42,
107
+ 42,
108
+ 1,
109
+ 24,
110
+ 24
111
+ ],
112
+ "output": 33
113
+ }
114
+ ],
115
+ "haskell_template": "duplicateNumbersXOR :: [Int] -> Int\nduplicateNumbersXOR nums ",
116
+ "ocaml_template": "let duplicateNumbersXOR (nums: int list) : int = ",
117
+ "scala_template": "def duplicateNumbersXOR(nums: List[Int]): Int = { \n \n}",
118
+ "java_template": "class Solution {\n public int duplicateNumbersXOR(int[] nums) {\n \n }\n}",
119
+ "python_template": "class Solution(object):\n def duplicateNumbersXOR(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
120
+ }
find_the_xor_of_numbers_which_appear_twice/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let duplicateNumbersXOR (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 1 (duplicateNumbersXOR [1;2;1;3])
13
+
14
+ let test2 _ = assert_equal 0 (duplicateNumbersXOR [1;2;3])
15
+
16
+ let test3 _ = assert_equal 3 (duplicateNumbersXOR [1;2;2;1])
17
+
18
+ let test4 _ = assert_equal 3 (duplicateNumbersXOR [13; 13; 31; 31; 31; 1; 38; 38; 49; 10; 10; 20; 20; 45; 45; 13])
19
+
20
+ let test5 _ = assert_equal 3 (duplicateNumbersXOR [38; 15; 15; 44; 19; 44; 35; 35; 31; 6; 6; 33; 34; 16; 16; 36; 36; 47; 20])
21
+
22
+ let test6 _ = assert_equal 3 (duplicateNumbersXOR [23; 27; 27; 3; 21])
23
+
24
+ let test7 _ = assert_equal 3 (duplicateNumbersXOR [10; 32; 21; 21; 3; 3; 13; 24; 24; 10; 21; 18; 44; 44; 16])
25
+
26
+ let test8 _ = assert_equal 3 (duplicateNumbersXOR [19; 19; 36; 42; 42; 1; 24; 24])
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for duplicateNumbersXOR" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end
find_the_xor_of_numbers_which_appear_twice/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.duplicateNumbersXOR(List(1,2,1,3)), 1)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.duplicateNumbersXOR(List(1,2,3)), 0)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.duplicateNumbersXOR(List(1,2,2,1)), 3)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.duplicateNumbersXOR(13,13,31,31,31,1,38,38,49,10,10,20,20,45,45,13), 21)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.duplicateNumbersXOR(38,15,15,44,19,44,35,35,31,6,6,33,34,16,16,36,36,47,20), 50)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.duplicateNumbersXOR(23,27,27,3,21), 27)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.duplicateNumbersXOR(10,32,21,21,3,3,13,24,24,10,21,18,44,44,16), 61)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.duplicateNumbersXOR(19,19,36,42,42,1,24,24), 33)
34
+ }
35
+
36
+ }
find_triangular_sum_of_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
find_triangular_sum_of_an_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (triangularSum [1,2,3,4,5])," 8 (triangularSum [1,2,3,4,5]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (triangularSum [5])," 5 (triangularSum [5]))
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_triangular_sum_of_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(8, triangularSum(new ArrayList<>(Arrays.asList(1,2,3,4,5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(5, triangularSum(new ArrayList<>(Arrays.asList(5))));
19
+ }
20
+
21
+ }
find_triangular_sum_of_an_array/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_triangular_sum_of_an_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 8 (triangularSum [1;2;3;4;5])
12
+
13
+ let test2 _ = assert_equal 5 (triangularSum [5])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for triangularSum" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
find_triangular_sum_of_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.triangularSum(List(1,2,3,4,5)), 8)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.triangularSum(List(5)), 5)
10
+ }
11
+
12
+ }
find_valid_pair_of_adjacent_digits_in_string/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ findValidPair :: String -> String
7
+ findValidPair s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (findValidPair \"2523533 \")," "23" (findValidPair "2523533"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (findValidPair \"221 \")," "21" (findValidPair "221"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (findValidPair \"22 \")," "" (findValidPair "22"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (findValidPair \"756792558394331287478821833597524455433271579117133449657 \")," "" (findValidPair "756792558394331287478821833597524455433271579117133449657"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (findValidPair \"776518848252212842713961621571355915866157861337944729794669737 \")," "" (findValidPair "776518848252212842713961621571355915866157861337944729794669737"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (findValidPair \"55866565327817363612729266 \")," "" (findValidPair "55866565327817363612729266"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (findValidPair \"571827669574991189278818172334595724113191642915149396294781121763455874535672553942951147314215 \")," "" (findValidPair "571827669574991189278818172334595724113191642915149396294781121763455874535672553942951147314215"))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (findValidPair \"79946134548636737241834 \")," "" (findValidPair "79946134548636737241834"))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
find_valid_pair_of_adjacent_digits_in_string/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("2523533", findValidPair("2523533"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("221", findValidPair("221"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals("22", findValidPair("22"));
22
+ }
23
+
24
+ }
find_valid_pair_of_adjacent_digits_in_string/meta.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3736,
3
+ "name": "find_valid_pair_of_adjacent_digits_in_string",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/find-valid-pair-of-adjacent-digits-in-string/",
6
+ "date": "2025-01-18 00:00:00",
7
+ "task_description": "You are given a string `s` consisting only of digits. A **valid pair** is defined as two **adjacent** digits in `s` such that: The first digit is **not equal** to the second. Each digit in the pair appears in `s` **exactly** as many times as its numeric value. Return the first **valid pair** found in the string `s` when traversing from left to right. If no valid pair exists, return an empty string. **Example 1:** **Input:** s = \"2523533\" **Output:** \"23\" **Explanation:** Digit `'2'` appears 2 times and digit `'3'` appears 3 times. Each digit in the pair `\"23\"` appears in `s` exactly as many times as its numeric value. Hence, the output is `\"23\"`. **Example 2:** **Input:** s = \"221\" **Output:** \"21\" **Explanation:** Digit `'2'` appears 2 times and digit `'1'` appears 1 time. Hence, the output is `\"21\"`. **Example 3:** **Input:** s = \"22\" **Output:** \"\" **Explanation:** There are no valid adjacent pairs. **Constraints:** `2 <= s.length <= 100` `s` only consists of digits from `'1'` to `'9'`.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"2523533\"",
12
+ "output": "\"23\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"221\"",
17
+ "output": "\"21\" "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "s = \"22\"",
22
+ "output": "\"\" "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": "756792558394331287478821833597524455433271579117133449657",
28
+ "output": ""
29
+ },
30
+ {
31
+ "input": "776518848252212842713961621571355915866157861337944729794669737",
32
+ "output": ""
33
+ },
34
+ {
35
+ "input": "55866565327817363612729266",
36
+ "output": ""
37
+ },
38
+ {
39
+ "input": "571827669574991189278818172334595724113191642915149396294781121763455874535672553942951147314215",
40
+ "output": ""
41
+ },
42
+ {
43
+ "input": "79946134548636737241834",
44
+ "output": ""
45
+ }
46
+ ],
47
+ "haskell_template": "findValidPair :: String -> String\nfindValidPair s ",
48
+ "ocaml_template": "let findValidPair (s: string) : string = ",
49
+ "scala_template": "def findValidPair(s: String): String = { \n \n}",
50
+ "java_template": "class Solution {\n public String findValidPair(String s) {\n \n }\n}",
51
+ "python_template": "class Solution(object):\n def findValidPair(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
52
+ }
find_valid_pair_of_adjacent_digits_in_string/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let findValidPair (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "23" (findValidPair "2523533")
13
+
14
+ let test2 _ = assert_equal "21" (findValidPair "221")
15
+
16
+ let test3 _ = assert_equal "" (findValidPair "22")
17
+
18
+ let test4 _ = assert_equal "" (findValidPair "756792558394331287478821833597524455433271579117133449657")
19
+
20
+ let test5 _ = assert_equal "" (findValidPair "776518848252212842713961621571355915866157861337944729794669737")
21
+
22
+ let test6 _ = assert_equal "" (findValidPair "55866565327817363612729266")
23
+
24
+ let test7 _ = assert_equal "" (findValidPair "571827669574991189278818172334595724113191642915149396294781121763455874535672553942951147314215")
25
+
26
+ let test8 _ = assert_equal "" (findValidPair "79946134548636737241834")
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for findValidPair" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end
find_valid_pair_of_adjacent_digits_in_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findValidPair("2523533"), "23")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findValidPair("221"), "21")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findValidPair("22"), "")
14
+ }
15
+
16
+ }
find_words_containing_character/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(0,1)), findWordsContaining(new ArrayList<>(Arrays.asList("leet","code")), "e"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0,2)), findWordsContaining(new ArrayList<>(Arrays.asList("abc","bcd","aaaa","cbc")), "a"));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals([], findWordsContaining(new ArrayList<>(Arrays.asList("abc","bcd","aaaa","cbc")), "z"));
23
+ }
24
+
25
+ }
find_x_sum_of_all_k_long_subarrays_i/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 (findXSum [1,1,2,2,3,4,2,3] 6 2)," [6,10,12] (findXSum [1,1,2,2,3,4,2,3] 6 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (findXSum [3,8,7,8,7,5] 2 2)," [11,15,15,15,12] (findXSum [3,8,7,8,7,5] 2 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (findXSum [2, 37, 16, 16, 44, 19, 33, 35, 17, 50, 45, 2, 2, 33, 8] 2 1)," [37,37,32,44,44,33,35,35,50,50,45,4,33,33] (findXSum [2, 37, 16, 16, 44, 19, 33, 35, 17, 50, 45, 2, 2, 33, 8] 2 1))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (findXSum [6, 26] 2 2)," [32] (findXSum [6, 26] 2 2))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (findXSum [30, 38, 11, 11, 24, 22, 49, 18] 5 1)," [22,22,22,49] (findXSum [30, 38, 11, 11, 24, 22, 49, 18] 5 1))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (findXSum [14, 11, 30, 6, 38, 20, 36, 15, 41, 13] 3 1)," [30,30,38,38,38,36,41,41] (findXSum [14, 11, 30, 6, 38, 20, 36, 15, 41, 13] 3 1))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (findXSum [39, 17, 26, 41, 25, 10, 14, 12] 5 4)," [131,109,106,92] (findXSum [39, 17, 26, 41, 25, 10, 14, 12] 5 4))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (findXSum [30, 41, 16, 1, 2, 32, 7, 39, 14, 6, 16, 20, 44, 17, 32, 21, 4, 36, 6, 43, 21, 36, 33, 25, 47, 21, 25] 9 4)," [142,128,117,107,135,135,135,136,117,133,133,155,165,189,190,190,195,204,182] (findXSum [30, 41, 16, 1, 2, 32, 7, 39, 14, 6, 16, 20, 44, 17, 32, 21, 4, 36, 6, 43, 21, 36, 33, 25, 47, 21, 25] 9 4))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (findXSum [9, 46, 14, 44, 47, 16, 45, 14, 13, 17, 12, 2, 30, 30, 9, 25, 4, 2, 29, 39] 14 7)," [287,287,266,254,214,196,219] (findXSum [9, 46, 14, 44, 47, 16, 45, 14, 13, 17, 12, 2, 30, 30, 9, 25, 4, 2, 29, 39] 14 7))
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_x_sum_of_all_k_long_subarrays_i/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(6,10,12)), findXSum(new ArrayList<>(Arrays.asList(1,1,2,2,3,4,2,3)), 6, 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(11,15,15,15,12)), findXSum(new ArrayList<>(Arrays.asList(3,8,7,8,7,5)), 2, 2));
19
+ }
20
+
21
+ }
find_x_sum_of_all_k_long_subarrays_i/meta.json ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3610,
3
+ "name": "find_x_sum_of_all_k_long_subarrays_i",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/",
6
+ "date": "2024-10-06 00:00:00",
7
+ "task_description": "You are given an array `nums` of `n` integers and two integers `k` and `x`. The **x-sum** of an array is calculated by the following procedure: Count the occurrences of all elements in the array. Keep only the occurrences of the top `x` most frequent elements. If two elements have the same number of occurrences, the element with the **bigger** value is considered more frequent. Calculate the sum of the resulting array. **Note** that if an array has less than `x` distinct elements, its **x-sum** is the sum of the array. Return an integer array `answer` of length `n - k + 1` where `answer[i]` is the **x-sum** of the subarray `nums[i..i + k - 1]`. **Example 1:** **Input:** nums = [1,1,2,2,3,4,2,3], k = 6, x = 2 **Output:** [6,10,12] **Explanation:** For subarray `[1, 1, 2, 2, 3, 4]`, only elements 1 and 2 will be kept in the resulting array. Hence, `answer[0] = 1 + 1 + 2 + 2`. For subarray `[1, 2, 2, 3, 4, 2]`, only elements 2 and 4 will be kept in the resulting array. Hence, `answer[1] = 2 + 2 + 2 + 4`. Note that 4 is kept in the array since it is bigger than 3 and 1 which occur the same number of times. For subarray `[2, 2, 3, 4, 2, 3]`, only elements 2 and 3 are kept in the resulting array. Hence, `answer[2] = 2 + 2 + 2 + 3 + 3`. **Example 2:** **Input:** nums = [3,8,7,8,7,5], k = 2, x = 2 **Output:** [11,15,15,15,12] **Explanation:** Since `k == x`, `answer[i]` is equal to the sum of the subarray `nums[i..i + k - 1]`. **Constraints:** `1 <= n == nums.length <= 50` `1 <= nums[i] <= 50` `1 <= x <= k <= nums.length`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,1,2,2,3,4,2,3], k = 6, x = 2",
12
+ "output": "[6,10,12] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [3,8,7,8,7,5], k = 2, x = 2",
17
+ "output": "[11,15,15,15,12] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 2,
25
+ 37,
26
+ 16,
27
+ 16,
28
+ 44,
29
+ 19,
30
+ 33,
31
+ 35,
32
+ 17,
33
+ 50,
34
+ 45,
35
+ 2,
36
+ 2,
37
+ 33,
38
+ 8
39
+ ],
40
+ 2,
41
+ 1
42
+ ],
43
+ "output": [
44
+ 37,
45
+ 37,
46
+ 32,
47
+ 44,
48
+ 44,
49
+ 33,
50
+ 35,
51
+ 35,
52
+ 50,
53
+ 50,
54
+ 45,
55
+ 4,
56
+ 33,
57
+ 33
58
+ ]
59
+ },
60
+ {
61
+ "input": [
62
+ [
63
+ 6,
64
+ 26
65
+ ],
66
+ 2,
67
+ 2
68
+ ],
69
+ "output": [
70
+ 32
71
+ ]
72
+ },
73
+ {
74
+ "input": [
75
+ [
76
+ 30,
77
+ 38,
78
+ 11,
79
+ 11,
80
+ 24,
81
+ 22,
82
+ 49,
83
+ 18
84
+ ],
85
+ 5,
86
+ 1
87
+ ],
88
+ "output": [
89
+ 22,
90
+ 22,
91
+ 22,
92
+ 49
93
+ ]
94
+ },
95
+ {
96
+ "input": [
97
+ [
98
+ 14,
99
+ 11,
100
+ 30,
101
+ 6,
102
+ 38,
103
+ 20,
104
+ 36,
105
+ 15,
106
+ 41,
107
+ 13
108
+ ],
109
+ 3,
110
+ 1
111
+ ],
112
+ "output": [
113
+ 30,
114
+ 30,
115
+ 38,
116
+ 38,
117
+ 38,
118
+ 36,
119
+ 41,
120
+ 41
121
+ ]
122
+ },
123
+ {
124
+ "input": [
125
+ [
126
+ 39,
127
+ 17,
128
+ 26,
129
+ 41,
130
+ 25,
131
+ 10,
132
+ 14,
133
+ 12
134
+ ],
135
+ 5,
136
+ 4
137
+ ],
138
+ "output": [
139
+ 131,
140
+ 109,
141
+ 106,
142
+ 92
143
+ ]
144
+ },
145
+ {
146
+ "input": [
147
+ [
148
+ 30,
149
+ 41,
150
+ 16,
151
+ 1,
152
+ 2,
153
+ 32,
154
+ 7,
155
+ 39,
156
+ 14,
157
+ 6,
158
+ 16,
159
+ 20,
160
+ 44,
161
+ 17,
162
+ 32,
163
+ 21,
164
+ 4,
165
+ 36,
166
+ 6,
167
+ 43,
168
+ 21,
169
+ 36,
170
+ 33,
171
+ 25,
172
+ 47,
173
+ 21,
174
+ 25
175
+ ],
176
+ 9,
177
+ 4
178
+ ],
179
+ "output": [
180
+ 142,
181
+ 128,
182
+ 117,
183
+ 107,
184
+ 135,
185
+ 135,
186
+ 135,
187
+ 136,
188
+ 117,
189
+ 133,
190
+ 133,
191
+ 155,
192
+ 165,
193
+ 189,
194
+ 190,
195
+ 190,
196
+ 195,
197
+ 204,
198
+ 182
199
+ ]
200
+ },
201
+ {
202
+ "input": [
203
+ [
204
+ 9,
205
+ 46,
206
+ 14,
207
+ 44,
208
+ 47,
209
+ 16,
210
+ 45,
211
+ 14,
212
+ 13,
213
+ 17,
214
+ 12,
215
+ 2,
216
+ 30,
217
+ 30,
218
+ 9,
219
+ 25,
220
+ 4,
221
+ 2,
222
+ 29,
223
+ 39
224
+ ],
225
+ 14,
226
+ 7
227
+ ],
228
+ "output": [
229
+ 287,
230
+ 287,
231
+ 266,
232
+ 254,
233
+ 214,
234
+ 196,
235
+ 219
236
+ ]
237
+ },
238
+ {
239
+ "input": [
240
+ [
241
+ 46,
242
+ 8,
243
+ 9,
244
+ 11,
245
+ 19,
246
+ 22,
247
+ 45,
248
+ 5,
249
+ 15,
250
+ 22,
251
+ 39,
252
+ 12,
253
+ 47,
254
+ 25,
255
+ 26,
256
+ 36,
257
+ 5,
258
+ 25,
259
+ 14,
260
+ 45,
261
+ 26,
262
+ 36,
263
+ 4,
264
+ 20,
265
+ 43,
266
+ 48,
267
+ 45,
268
+ 19,
269
+ 6,
270
+ 23
271
+ ],
272
+ 30,
273
+ 8
274
+ ],
275
+ "output": [
276
+ 449
277
+ ]
278
+ },
279
+ {
280
+ "input": [
281
+ [
282
+ 24,
283
+ 5
284
+ ],
285
+ 2,
286
+ 1
287
+ ],
288
+ "output": [
289
+ 24
290
+ ]
291
+ },
292
+ {
293
+ "input": [
294
+ [
295
+ 21,
296
+ 3,
297
+ 47,
298
+ 33,
299
+ 8,
300
+ 33,
301
+ 33,
302
+ 34,
303
+ 14,
304
+ 27,
305
+ 15,
306
+ 21,
307
+ 6,
308
+ 39,
309
+ 39,
310
+ 31,
311
+ 33,
312
+ 29
313
+ ],
314
+ 7,
315
+ 1
316
+ ],
317
+ "output": [
318
+ 99,
319
+ 99,
320
+ 99,
321
+ 99,
322
+ 66,
323
+ 66,
324
+ 34,
325
+ 39,
326
+ 78,
327
+ 78,
328
+ 78,
329
+ 78
330
+ ]
331
+ }
332
+ ],
333
+ "haskell_template": "findXSum :: [Int] -> Int -> Int -> [Int]\nfindXSum nums k x ",
334
+ "ocaml_template": "let findXSum (nums: int list) (k: int) (x: int) : int list = ",
335
+ "scala_template": "def findXSum(nums: List[Int],k: Int,x: Int): List[Int] = { \n \n}",
336
+ "java_template": "class Solution {\n public int[] findXSum(int[] nums, int k, int x) {\n \n }\n}",
337
+ "python_template": "class Solution(object):\n def findXSum(self, nums, k, x):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :type x: int\n :rtype: List[int]\n \"\"\"\n "
338
+ }
find_x_sum_of_all_k_long_subarrays_i/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;10;12] (findXSum [1;1;2;2;3;4;2;3] 6 2)
12
+
13
+ let test2 _ = assert_equal [11;15;15;15;12] (findXSum [3;8;7;8;7;5] 2 2)
14
+
15
+ let test3 _ = assert_equal [37;37;32;44;44;33;35;35;50;50;45;4;33;33] (findXSum [2; 37; 16; 16; 44; 19; 33; 35; 17; 50; 45; 2; 2; 33; 8] 2 1)
16
+
17
+ let test4 _ = assert_equal [32] (findXSum [6; 26] 2 2)
18
+
19
+ let test5 _ = assert_equal [22;22;22;49] (findXSum [30; 38; 11; 11; 24; 22; 49; 18] 5 1)
20
+
21
+ let test6 _ = assert_equal [30;30;38;38;38;36;41;41] (findXSum [14; 11; 30; 6; 38; 20; 36; 15; 41; 13] 3 1)
22
+
23
+ let test7 _ = assert_equal [131;109;106;92] (findXSum [39; 17; 26; 41; 25; 10; 14; 12] 5 4)
24
+
25
+ let test8 _ = assert_equal [142;128;117;107;135;135;135;136;117;133;133;155;165;189;190;190;195;204;182] (findXSum [30; 41; 16; 1; 2; 32; 7; 39; 14; 6; 16; 20; 44; 17; 32; 21; 4; 36; 6; 43; 21; 36; 33; 25; 47; 21; 25] 9 4)
26
+
27
+ let test9 _ = assert_equal [287;287;266;254;214;196;219] (findXSum [9; 46; 14; 44; 47; 16; 45; 14; 13; 17; 12; 2; 30; 30; 9; 25; 4; 2; 29; 39] 14 7)
28
+
29
+ let test10 _ = assert_equal [449] (findXSum [46; 8; 9; 11; 19; 22; 45; 5; 15; 22; 39; 12; 47; 25; 26; 36; 5; 25; 14; 45; 26; 36; 4; 20; 43; 48; 45; 19; 6; 23] 30 8)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for findXSum" >::: [
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_x_sum_of_all_k_long_subarrays_i/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findXSum(List(1,1,2,2,3,4,2,3),6,2), List(6,10,12))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findXSum(List(3,8,7,8,7,5),2,2), List(11,15,15,15,12))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findXSum(List(2, 37, 16, 16, 44, 19, 33, 35, 17, 50, 45, 2, 2, 33, 8),2,1), List(37,37,32,44,44,33,35,35,50,50,45,4,33,33))
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.findXSum(List(6, 26),2,2), List(32))
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.findXSum(List(30, 38, 11, 11, 24, 22, 49, 18),5,1), List(22,22,22,49))
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.findXSum(List(14, 11, 30, 6, 38, 20, 36, 15, 41, 13),3,1), List(30,30,38,38,38,36,41,41))
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.findXSum(List(39, 17, 26, 41, 25, 10, 14, 12),5,4), List(131,109,106,92))
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.findXSum(List(30, 41, 16, 1, 2, 32, 7, 39, 14, 6, 16, 20, 44, 17, 32, 21, 4, 36, 6, 43, 21, 36, 33, 25, 47, 21, 25),9,4), List(142,128,117,107,135,135,135,136,117,133,133,155,165,189,190,190,195,204,182))
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.findXSum(List(9, 46, 14, 44, 47, 16, 45, 14, 13, 17, 12, 2, 30, 30, 9, 25, 4, 2, 29, 39),14,7), List(287,287,266,254,214,196,219))
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.findXSum(List(46, 8, 9, 11, 19, 22, 45, 5, 15, 22, 39, 12, 47, 25, 26, 36, 5, 25, 14, 45, 26, 36, 4, 20, 43, 48, 45, 19, 6, 23),30,8), List(449))
42
+ }
43
+
44
+ }
find_x_sum_of_all_k_long_subarrays_ii/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:037a8c036bfd4c2504d465968900ba08412e1b2075b2e8480e342b9f05e636d2
3
+ size 12012115
find_x_sum_of_all_k_long_subarrays_ii/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(6,10,12)), findXSum(new ArrayList<>(Arrays.asList(1,1,2,2,3,4,2,3)), 6, 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(11,15,15,15,12)), findXSum(new ArrayList<>(Arrays.asList(3,8,7,8,7,5)), 2, 2));
19
+ }
20
+
21
+ }
find_x_sum_of_all_k_long_subarrays_ii/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4622f39472627fdd0fd3044ca18d85e143d334c9a13960a6eeb4c6f9eda8c86f
3
+ size 19596875
find_x_sum_of_all_k_long_subarrays_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_x_sum_of_all_k_long_subarrays_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
find_xor_beauty_of_array/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
find_xor_beauty_of_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(5, xorBeauty(Arrays.asList(1,4)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(34, xorBeauty(Arrays.asList(15,45,20,2,34,35,5,44,32,30)));
18
+ }
19
+
20
+ }
find_xor_beauty_of_array/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
find_xor_beauty_of_array/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
find_xor_beauty_of_array/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
first_completely_painted_row_or_column/.DS_Store ADDED
Binary file (6.15 kB). View file
 
first_completely_painted_row_or_column/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 (firstCompleteIndex [1,3,4,2] [[1,4],[2,3]])," 2 (firstCompleteIndex [1,3,4,2] [[1,4],[2,3]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (firstCompleteIndex [2,8,7,4,1,3,5,6,9] [[3,2,5],[1,4,6],[8,7,9]])," 3 (firstCompleteIndex [2,8,7,4,1,3,5,6,9] [[3,2,5],[1,4,6],[8,7,9]]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
first_completely_painted_row_or_column/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, firstCompleteIndex(new ArrayList<>(Arrays.asList(1,3,4,2)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,4)),new ArrayList<>(Arrays.asList(2,3))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, firstCompleteIndex(new ArrayList<>(Arrays.asList(2,8,7,4,1,3,5,6,9)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,2,5)),new ArrayList<>(Arrays.asList(1,4,6)),new ArrayList<>(Arrays.asList(8,7,9))))));
19
+ }
20
+
21
+ }
first_completely_painted_row_or_column/meta.json ADDED
@@ -0,0 +1,1089 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2685,
3
+ "name": "first_completely_painted_row_or_column",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/first-completely-painted-row-or-column/",
6
+ "date": "1682208000000",
7
+ "task_description": "You are given a **0-indexed** integer array `arr`, and an `m x n` integer **matrix** `mat`. `arr` and `mat` both contain **all** the integers in the range `[1, m * n]`. Go through each index `i` in `arr` starting from index `0` and paint the cell in `mat` containing the integer `arr[i]`. Return _the smallest index_ `i` _at which either a row or a column will be completely painted in_ `mat`. **Example 1:** ``` **Input:** arr = [1,3,4,2], mat = [[1,4],[2,3]] **Output:** 2 **Explanation:** The moves are shown in order, and both the first row and second column of the matrix become fully painted at arr[2]. ``` **Example 2:** ``` **Input:** arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]] **Output:** 3 **Explanation:** The second column becomes fully painted at arr[3]. ``` **Constraints:** `m == mat.length` `n = mat[i].length` `arr.length == m * n` `1 <= m, n <= 105` `1 <= m * n <= 105` `1 <= arr[i], mat[r][c] <= m * n` All the integers of `arr` are **unique**. All the integers of `mat` are **unique**.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "arr = [1,3,4,2], mat = [[1,4],[2,3]]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "arr = [2,8,7,4,1,3,5,6,9], mat = [[3,2,5],[1,4,6],[8,7,9]]",
17
+ "output": "3 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 67,
25
+ 23,
26
+ 70,
27
+ 9,
28
+ 40,
29
+ 61,
30
+ 45,
31
+ 25,
32
+ 47,
33
+ 19,
34
+ 30,
35
+ 18,
36
+ 58,
37
+ 39,
38
+ 15,
39
+ 66,
40
+ 35,
41
+ 20,
42
+ 8,
43
+ 7,
44
+ 54,
45
+ 6,
46
+ 41,
47
+ 34,
48
+ 53,
49
+ 10,
50
+ 60,
51
+ 43,
52
+ 63,
53
+ 13,
54
+ 68,
55
+ 4,
56
+ 16,
57
+ 31,
58
+ 52,
59
+ 22,
60
+ 49,
61
+ 27,
62
+ 57,
63
+ 69,
64
+ 29,
65
+ 12,
66
+ 48,
67
+ 24,
68
+ 1,
69
+ 50,
70
+ 64,
71
+ 17,
72
+ 44,
73
+ 3,
74
+ 51,
75
+ 14,
76
+ 59,
77
+ 46,
78
+ 28,
79
+ 2,
80
+ 36,
81
+ 65,
82
+ 32,
83
+ 42,
84
+ 5,
85
+ 55,
86
+ 62,
87
+ 26,
88
+ 38,
89
+ 56,
90
+ 37,
91
+ 11,
92
+ 33,
93
+ 21
94
+ ],
95
+ [
96
+ [
97
+ 67,
98
+ 23,
99
+ 70,
100
+ 9,
101
+ 40,
102
+ 61,
103
+ 45,
104
+ 25,
105
+ 47,
106
+ 19
107
+ ],
108
+ [
109
+ 30,
110
+ 18,
111
+ 58,
112
+ 39,
113
+ 15,
114
+ 66,
115
+ 35,
116
+ 20,
117
+ 8,
118
+ 7
119
+ ],
120
+ [
121
+ 54,
122
+ 6,
123
+ 41,
124
+ 34,
125
+ 53,
126
+ 10,
127
+ 60,
128
+ 43,
129
+ 63,
130
+ 13
131
+ ],
132
+ [
133
+ 68,
134
+ 4,
135
+ 16,
136
+ 31,
137
+ 52,
138
+ 22,
139
+ 49,
140
+ 27,
141
+ 57,
142
+ 69
143
+ ],
144
+ [
145
+ 29,
146
+ 12,
147
+ 48,
148
+ 24,
149
+ 1,
150
+ 50,
151
+ 64,
152
+ 17,
153
+ 44,
154
+ 3
155
+ ],
156
+ [
157
+ 51,
158
+ 14,
159
+ 59,
160
+ 46,
161
+ 28,
162
+ 2,
163
+ 36,
164
+ 65,
165
+ 32,
166
+ 42
167
+ ],
168
+ [
169
+ 5,
170
+ 55,
171
+ 62,
172
+ 26,
173
+ 38,
174
+ 56,
175
+ 37,
176
+ 11,
177
+ 33,
178
+ 21
179
+ ]
180
+ ]
181
+ ],
182
+ "output": 9
183
+ },
184
+ {
185
+ "input": [
186
+ [
187
+ 37,
188
+ 17,
189
+ 42,
190
+ 38,
191
+ 31,
192
+ 4,
193
+ 41,
194
+ 8,
195
+ 12,
196
+ 28,
197
+ 10,
198
+ 2,
199
+ 26,
200
+ 32,
201
+ 36,
202
+ 16,
203
+ 45,
204
+ 23,
205
+ 15,
206
+ 30,
207
+ 7,
208
+ 35,
209
+ 25,
210
+ 43,
211
+ 1,
212
+ 3,
213
+ 47,
214
+ 39,
215
+ 27,
216
+ 34,
217
+ 13,
218
+ 50,
219
+ 6,
220
+ 49,
221
+ 5,
222
+ 22,
223
+ 33,
224
+ 11,
225
+ 29,
226
+ 44,
227
+ 18,
228
+ 24,
229
+ 21,
230
+ 40,
231
+ 20,
232
+ 19,
233
+ 48,
234
+ 46,
235
+ 9,
236
+ 14
237
+ ],
238
+ [
239
+ [
240
+ 37,
241
+ 17,
242
+ 42,
243
+ 38,
244
+ 31
245
+ ],
246
+ [
247
+ 4,
248
+ 41,
249
+ 8,
250
+ 12,
251
+ 28
252
+ ],
253
+ [
254
+ 10,
255
+ 2,
256
+ 26,
257
+ 32,
258
+ 36
259
+ ],
260
+ [
261
+ 16,
262
+ 45,
263
+ 23,
264
+ 15,
265
+ 30
266
+ ],
267
+ [
268
+ 7,
269
+ 35,
270
+ 25,
271
+ 43,
272
+ 1
273
+ ],
274
+ [
275
+ 3,
276
+ 47,
277
+ 39,
278
+ 27,
279
+ 34
280
+ ],
281
+ [
282
+ 13,
283
+ 50,
284
+ 6,
285
+ 49,
286
+ 5
287
+ ],
288
+ [
289
+ 22,
290
+ 33,
291
+ 11,
292
+ 29,
293
+ 44
294
+ ],
295
+ [
296
+ 18,
297
+ 24,
298
+ 21,
299
+ 40,
300
+ 20
301
+ ],
302
+ [
303
+ 19,
304
+ 48,
305
+ 46,
306
+ 9,
307
+ 14
308
+ ]
309
+ ]
310
+ ],
311
+ "output": 4
312
+ },
313
+ {
314
+ "input": [
315
+ [
316
+ 5,
317
+ 2,
318
+ 3,
319
+ 1,
320
+ 6,
321
+ 4,
322
+ 7
323
+ ],
324
+ [
325
+ [
326
+ 5,
327
+ 2,
328
+ 3,
329
+ 1,
330
+ 6,
331
+ 4,
332
+ 7
333
+ ]
334
+ ]
335
+ ],
336
+ "output": 0
337
+ },
338
+ {
339
+ "input": [
340
+ [
341
+ 66,
342
+ 57,
343
+ 19,
344
+ 17,
345
+ 29,
346
+ 50,
347
+ 87,
348
+ 20,
349
+ 8,
350
+ 37,
351
+ 16,
352
+ 43,
353
+ 84,
354
+ 3,
355
+ 78,
356
+ 49,
357
+ 13,
358
+ 36,
359
+ 89,
360
+ 70,
361
+ 79,
362
+ 86,
363
+ 40,
364
+ 1,
365
+ 2,
366
+ 18,
367
+ 27,
368
+ 42,
369
+ 48,
370
+ 28,
371
+ 6,
372
+ 47,
373
+ 81,
374
+ 31,
375
+ 15,
376
+ 26,
377
+ 25,
378
+ 5,
379
+ 88,
380
+ 67,
381
+ 44,
382
+ 53,
383
+ 54,
384
+ 52,
385
+ 56,
386
+ 45,
387
+ 55,
388
+ 63,
389
+ 38,
390
+ 83,
391
+ 11,
392
+ 85,
393
+ 60,
394
+ 14,
395
+ 10,
396
+ 68,
397
+ 90,
398
+ 61,
399
+ 24,
400
+ 22,
401
+ 71,
402
+ 72,
403
+ 32,
404
+ 12,
405
+ 64,
406
+ 7,
407
+ 74,
408
+ 4,
409
+ 21,
410
+ 39,
411
+ 59,
412
+ 58,
413
+ 30,
414
+ 34,
415
+ 35,
416
+ 77,
417
+ 76,
418
+ 75,
419
+ 46,
420
+ 51,
421
+ 80,
422
+ 9,
423
+ 33,
424
+ 82,
425
+ 62,
426
+ 73,
427
+ 65,
428
+ 41,
429
+ 69,
430
+ 23
431
+ ],
432
+ [
433
+ [
434
+ 66,
435
+ 57,
436
+ 19,
437
+ 17,
438
+ 29,
439
+ 50,
440
+ 87,
441
+ 20,
442
+ 8,
443
+ 37
444
+ ],
445
+ [
446
+ 16,
447
+ 43,
448
+ 84,
449
+ 3,
450
+ 78,
451
+ 49,
452
+ 13,
453
+ 36,
454
+ 89,
455
+ 70
456
+ ],
457
+ [
458
+ 79,
459
+ 86,
460
+ 40,
461
+ 1,
462
+ 2,
463
+ 18,
464
+ 27,
465
+ 42,
466
+ 48,
467
+ 28
468
+ ],
469
+ [
470
+ 6,
471
+ 47,
472
+ 81,
473
+ 31,
474
+ 15,
475
+ 26,
476
+ 25,
477
+ 5,
478
+ 88,
479
+ 67
480
+ ],
481
+ [
482
+ 44,
483
+ 53,
484
+ 54,
485
+ 52,
486
+ 56,
487
+ 45,
488
+ 55,
489
+ 63,
490
+ 38,
491
+ 83
492
+ ],
493
+ [
494
+ 11,
495
+ 85,
496
+ 60,
497
+ 14,
498
+ 10,
499
+ 68,
500
+ 90,
501
+ 61,
502
+ 24,
503
+ 22
504
+ ],
505
+ [
506
+ 71,
507
+ 72,
508
+ 32,
509
+ 12,
510
+ 64,
511
+ 7,
512
+ 74,
513
+ 4,
514
+ 21,
515
+ 39
516
+ ],
517
+ [
518
+ 59,
519
+ 58,
520
+ 30,
521
+ 34,
522
+ 35,
523
+ 77,
524
+ 76,
525
+ 75,
526
+ 46,
527
+ 51
528
+ ],
529
+ [
530
+ 80,
531
+ 9,
532
+ 33,
533
+ 82,
534
+ 62,
535
+ 73,
536
+ 65,
537
+ 41,
538
+ 69,
539
+ 23
540
+ ]
541
+ ]
542
+ ],
543
+ "output": 9
544
+ },
545
+ {
546
+ "input": [
547
+ [
548
+ 47,
549
+ 35,
550
+ 34,
551
+ 10,
552
+ 42,
553
+ 9,
554
+ 38,
555
+ 8,
556
+ 49,
557
+ 40,
558
+ 52,
559
+ 32,
560
+ 16,
561
+ 25,
562
+ 12,
563
+ 30,
564
+ 48,
565
+ 2,
566
+ 7,
567
+ 44,
568
+ 26,
569
+ 45,
570
+ 1,
571
+ 13,
572
+ 54,
573
+ 15,
574
+ 50,
575
+ 43,
576
+ 11,
577
+ 37,
578
+ 3,
579
+ 23,
580
+ 17,
581
+ 36,
582
+ 27,
583
+ 51,
584
+ 39,
585
+ 29,
586
+ 41,
587
+ 53,
588
+ 19,
589
+ 24,
590
+ 20,
591
+ 33,
592
+ 6,
593
+ 14,
594
+ 28,
595
+ 4,
596
+ 5,
597
+ 46,
598
+ 22,
599
+ 21,
600
+ 18,
601
+ 31
602
+ ],
603
+ [
604
+ [
605
+ 47,
606
+ 35,
607
+ 34,
608
+ 10,
609
+ 42,
610
+ 9,
611
+ 38,
612
+ 8,
613
+ 49
614
+ ],
615
+ [
616
+ 40,
617
+ 52,
618
+ 32,
619
+ 16,
620
+ 25,
621
+ 12,
622
+ 30,
623
+ 48,
624
+ 2
625
+ ],
626
+ [
627
+ 7,
628
+ 44,
629
+ 26,
630
+ 45,
631
+ 1,
632
+ 13,
633
+ 54,
634
+ 15,
635
+ 50
636
+ ],
637
+ [
638
+ 43,
639
+ 11,
640
+ 37,
641
+ 3,
642
+ 23,
643
+ 17,
644
+ 36,
645
+ 27,
646
+ 51
647
+ ],
648
+ [
649
+ 39,
650
+ 29,
651
+ 41,
652
+ 53,
653
+ 19,
654
+ 24,
655
+ 20,
656
+ 33,
657
+ 6
658
+ ],
659
+ [
660
+ 14,
661
+ 28,
662
+ 4,
663
+ 5,
664
+ 46,
665
+ 22,
666
+ 21,
667
+ 18,
668
+ 31
669
+ ]
670
+ ]
671
+ ],
672
+ "output": 8
673
+ },
674
+ {
675
+ "input": [
676
+ [
677
+ 22,
678
+ 14,
679
+ 2,
680
+ 20,
681
+ 24,
682
+ 16,
683
+ 5,
684
+ 6,
685
+ 9,
686
+ 10,
687
+ 12,
688
+ 21,
689
+ 1,
690
+ 13,
691
+ 11,
692
+ 8,
693
+ 4,
694
+ 19,
695
+ 15,
696
+ 3,
697
+ 18,
698
+ 17,
699
+ 23,
700
+ 7
701
+ ],
702
+ [
703
+ [
704
+ 22,
705
+ 14,
706
+ 2,
707
+ 20,
708
+ 24,
709
+ 16
710
+ ],
711
+ [
712
+ 5,
713
+ 6,
714
+ 9,
715
+ 10,
716
+ 12,
717
+ 21
718
+ ],
719
+ [
720
+ 1,
721
+ 13,
722
+ 11,
723
+ 8,
724
+ 4,
725
+ 19
726
+ ],
727
+ [
728
+ 15,
729
+ 3,
730
+ 18,
731
+ 17,
732
+ 23,
733
+ 7
734
+ ]
735
+ ]
736
+ ],
737
+ "output": 5
738
+ },
739
+ {
740
+ "input": [
741
+ [
742
+ 40,
743
+ 16,
744
+ 15,
745
+ 28,
746
+ 26,
747
+ 43,
748
+ 22,
749
+ 31,
750
+ 49,
751
+ 10,
752
+ 4,
753
+ 29,
754
+ 2,
755
+ 32,
756
+ 11,
757
+ 21,
758
+ 47,
759
+ 45,
760
+ 20,
761
+ 41,
762
+ 13,
763
+ 48,
764
+ 44,
765
+ 38,
766
+ 46,
767
+ 19,
768
+ 36,
769
+ 23,
770
+ 5,
771
+ 12,
772
+ 8,
773
+ 35,
774
+ 9,
775
+ 14,
776
+ 27,
777
+ 1,
778
+ 33,
779
+ 24,
780
+ 3,
781
+ 34,
782
+ 18,
783
+ 37,
784
+ 7,
785
+ 50,
786
+ 42,
787
+ 17,
788
+ 25,
789
+ 30,
790
+ 6,
791
+ 39
792
+ ],
793
+ [
794
+ [
795
+ 40,
796
+ 16,
797
+ 15,
798
+ 28,
799
+ 26,
800
+ 43,
801
+ 22,
802
+ 31,
803
+ 49,
804
+ 10
805
+ ],
806
+ [
807
+ 4,
808
+ 29,
809
+ 2,
810
+ 32,
811
+ 11,
812
+ 21,
813
+ 47,
814
+ 45,
815
+ 20,
816
+ 41
817
+ ],
818
+ [
819
+ 13,
820
+ 48,
821
+ 44,
822
+ 38,
823
+ 46,
824
+ 19,
825
+ 36,
826
+ 23,
827
+ 5,
828
+ 12
829
+ ],
830
+ [
831
+ 8,
832
+ 35,
833
+ 9,
834
+ 14,
835
+ 27,
836
+ 1,
837
+ 33,
838
+ 24,
839
+ 3,
840
+ 34
841
+ ],
842
+ [
843
+ 18,
844
+ 37,
845
+ 7,
846
+ 50,
847
+ 42,
848
+ 17,
849
+ 25,
850
+ 30,
851
+ 6,
852
+ 39
853
+ ]
854
+ ]
855
+ ],
856
+ "output": 9
857
+ },
858
+ {
859
+ "input": [
860
+ [
861
+ 25,
862
+ 24,
863
+ 9,
864
+ 5,
865
+ 2,
866
+ 14,
867
+ 3,
868
+ 19,
869
+ 11,
870
+ 28,
871
+ 13,
872
+ 4,
873
+ 23,
874
+ 18,
875
+ 29,
876
+ 16,
877
+ 20,
878
+ 15,
879
+ 8,
880
+ 30,
881
+ 7,
882
+ 26,
883
+ 27,
884
+ 12,
885
+ 21,
886
+ 22,
887
+ 1,
888
+ 17,
889
+ 6,
890
+ 10
891
+ ],
892
+ [
893
+ [
894
+ 25,
895
+ 24,
896
+ 9
897
+ ],
898
+ [
899
+ 5,
900
+ 2,
901
+ 14
902
+ ],
903
+ [
904
+ 3,
905
+ 19,
906
+ 11
907
+ ],
908
+ [
909
+ 28,
910
+ 13,
911
+ 4
912
+ ],
913
+ [
914
+ 23,
915
+ 18,
916
+ 29
917
+ ],
918
+ [
919
+ 16,
920
+ 20,
921
+ 15
922
+ ],
923
+ [
924
+ 8,
925
+ 30,
926
+ 7
927
+ ],
928
+ [
929
+ 26,
930
+ 27,
931
+ 12
932
+ ],
933
+ [
934
+ 21,
935
+ 22,
936
+ 1
937
+ ],
938
+ [
939
+ 17,
940
+ 6,
941
+ 10
942
+ ]
943
+ ]
944
+ ],
945
+ "output": 2
946
+ },
947
+ {
948
+ "input": [
949
+ [
950
+ 33,
951
+ 9,
952
+ 34,
953
+ 29,
954
+ 39,
955
+ 20,
956
+ 38,
957
+ 35,
958
+ 7,
959
+ 21,
960
+ 28,
961
+ 13,
962
+ 23,
963
+ 19,
964
+ 40,
965
+ 4,
966
+ 17,
967
+ 2,
968
+ 14,
969
+ 5,
970
+ 27,
971
+ 12,
972
+ 24,
973
+ 22,
974
+ 15,
975
+ 8,
976
+ 30,
977
+ 16,
978
+ 3,
979
+ 10,
980
+ 1,
981
+ 6,
982
+ 26,
983
+ 18,
984
+ 32,
985
+ 11,
986
+ 36,
987
+ 31,
988
+ 25,
989
+ 37
990
+ ],
991
+ [
992
+ [
993
+ 33,
994
+ 9,
995
+ 34,
996
+ 29
997
+ ],
998
+ [
999
+ 39,
1000
+ 20,
1001
+ 38,
1002
+ 35
1003
+ ],
1004
+ [
1005
+ 7,
1006
+ 21,
1007
+ 28,
1008
+ 13
1009
+ ],
1010
+ [
1011
+ 23,
1012
+ 19,
1013
+ 40,
1014
+ 4
1015
+ ],
1016
+ [
1017
+ 17,
1018
+ 2,
1019
+ 14,
1020
+ 5
1021
+ ],
1022
+ [
1023
+ 27,
1024
+ 12,
1025
+ 24,
1026
+ 22
1027
+ ],
1028
+ [
1029
+ 15,
1030
+ 8,
1031
+ 30,
1032
+ 16
1033
+ ],
1034
+ [
1035
+ 3,
1036
+ 10,
1037
+ 1,
1038
+ 6
1039
+ ],
1040
+ [
1041
+ 26,
1042
+ 18,
1043
+ 32,
1044
+ 11
1045
+ ],
1046
+ [
1047
+ 36,
1048
+ 31,
1049
+ 25,
1050
+ 37
1051
+ ]
1052
+ ]
1053
+ ],
1054
+ "output": 3
1055
+ },
1056
+ {
1057
+ "input": [
1058
+ [
1059
+ 4,
1060
+ 5,
1061
+ 1,
1062
+ 3,
1063
+ 2,
1064
+ 6
1065
+ ],
1066
+ [
1067
+ [
1068
+ 4,
1069
+ 5
1070
+ ],
1071
+ [
1072
+ 1,
1073
+ 3
1074
+ ],
1075
+ [
1076
+ 2,
1077
+ 6
1078
+ ]
1079
+ ]
1080
+ ],
1081
+ "output": 1
1082
+ }
1083
+ ],
1084
+ "haskell_template": "firstCompleteIndex :: [Int] -> [[Int]] -> Int\nfirstCompleteIndex arr mat ",
1085
+ "ocaml_template": "let firstCompleteIndex (arr: int list) (mat: int list list) : int = ",
1086
+ "scala_template": "def firstCompleteIndex(arr: List[Int],mat: List[List[Int]]): Int = { \n \n}",
1087
+ "java_template": "public static int firstCompleteIndex(List<Integer> arr, List<List<Integer>> mat) {\n\n}",
1088
+ "python_template": "class Solution(object):\n def firstCompleteIndex(self, arr, mat):\n \"\"\"\n :type arr: List[int]\n :type mat: List[List[int]]\n :rtype: int\n \"\"\"\n "
1089
+ }
first_completely_painted_row_or_column/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 2 (firstCompleteIndex [1;3;4;2] [[1;4];[2;3]])
12
+
13
+ let test2 _ = assert_equal 3 (firstCompleteIndex [2;8;7;4;1;3;5;6;9] [[3;2;5];[1;4;6];[8;7;9]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for firstCompleteIndex" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
first_completely_painted_row_or_column/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.firstCompleteIndex(List(1,3,4,2),List(List(1,4),List(2,3))), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.firstCompleteIndex(List(2,8,7,4,1,3,5,6,9),List(List(3,2,5),List(1,4,6),List(8,7,9))), 3)
10
+ }
11
+
12
+ }
first_letter_to_appear_twice/.DS_Store ADDED
Binary file (6.15 kB). View file