diff --git a/.gitattributes b/.gitattributes index ba085f5bedcf22bf64220bacec30f48981cfd795..e77b68fcbb4c286448407055e95b01899f4aa4a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -92,3 +92,12 @@ count_the_number_of_good_nodes/haskell_tests/Main.hs filter=lfs diff=lfs merge=l count_the_number_of_good_nodes/meta.json filter=lfs diff=lfs merge=lfs -text count_the_number_of_good_subarrays/meta.json filter=lfs diff=lfs merge=lfs -text count_the_number_of_houses_at_a_certain_distance_ii/meta.json filter=lfs diff=lfs merge=lfs -text +count_unreachable_pairs_of_nodes_in_an_undirected_graph/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text +count_unreachable_pairs_of_nodes_in_an_undirected_graph/meta.json filter=lfs diff=lfs merge=lfs -text +count_unreachable_pairs_of_nodes_in_an_undirected_graph/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text +count_unreachable_pairs_of_nodes_in_an_undirected_graph/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text +count_ways_to_group_overlapping_ranges/meta.json filter=lfs diff=lfs merge=lfs -text +count_zero_request_servers/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text +count_zero_request_servers/meta.json filter=lfs diff=lfs merge=lfs -text +count_zero_request_servers/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text +count_zero_request_servers/scala_tests/MySuite.scala filter=lfs diff=lfs merge=lfs -text diff --git a/count_unguarded_cells_in_the_grid/.DS_Store b/count_unguarded_cells_in_the_grid/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..54102db8f30b7c8fc43677ae2b8e5132e990f9e6 Binary files /dev/null and b/count_unguarded_cells_in_the_grid/.DS_Store differ diff --git a/count_unguarded_cells_in_the_grid/haskell_tests/Main.hs b/count_unguarded_cells_in_the_grid/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..bfd2998b54c4869902e4cce6f8a8ad610d0105e4 --- /dev/null +++ b/count_unguarded_cells_in_the_grid/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (countUnguarded 4 6 [[0,0],[1,1],[2,3]] [[0,1],[2,2],[1,4]])," 7 (countUnguarded 4 6 [[0,0],[1,1],[2,3]] [[0,1],[2,2],[1,4]])) + +test2 :: Test +test2 = TestCase (assertEqual "for (countUnguarded 3 3 [[1,1]] [[0,1],[1,0],[2,1],[1,2]])," 4 (countUnguarded 3 3 [[1,1]] [[0,1],[1,0],[2,1],[1,2]])) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/count_unguarded_cells_in_the_grid/java_tests/Main.java b/count_unguarded_cells_in_the_grid/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..032d4edf69e7fc8567a6fe87f0d900bcb48ffc75 --- /dev/null +++ b/count_unguarded_cells_in_the_grid/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(7, countUnguarded(4, 6, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,0)),new ArrayList<>(Arrays.asList(1,1)),new ArrayList<>(Arrays.asList(2,3)))), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(2,2)),new ArrayList<>(Arrays.asList(1,4)))))); +} +@Test +public void test2() { + assertEquals(4, countUnguarded(3, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1)))), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(1,0)),new ArrayList<>(Arrays.asList(2,1)),new ArrayList<>(Arrays.asList(1,2)))))); +} + +} diff --git a/count_unguarded_cells_in_the_grid/meta.json b/count_unguarded_cells_in_the_grid/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..e9c2fe9cd187963ff7b657e94f4465b3d6461e8e --- /dev/null +++ b/count_unguarded_cells_in_the_grid/meta.json @@ -0,0 +1,2173 @@ +{ + "id": 2343, + "name": "count_unguarded_cells_in_the_grid", + "difficulty": "Medium", + "link": "https://leetcode.com/problems/count-unguarded-cells-in-the-grid/", + "date": "1650067200000", + "task_description": "You are given two integers `m` and `n` representing a **0-indexed** `m x n` grid. You are also given two 2D integer arrays `guards` and `walls` where `guards[i] = [rowi, coli]` and `walls[j] = [rowj, colj]` represent the positions of the `ith` guard and `jth` wall respectively. A guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless **obstructed** by a wall or another guard. A cell is **guarded** if there is **at least** one guard that can see it. Return_ the number of unoccupied cells that are **not** **guarded**._ **Example 1:** ``` **Input:** m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]] **Output:** 7 **Explanation:** The guarded and unguarded cells are shown in red and green respectively in the above diagram. There are a total of 7 unguarded cells, so we return 7. ``` **Example 2:** ``` **Input:** m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]] **Output:** 4 **Explanation:** The unguarded cells are shown in green in the above diagram. There are a total of 4 unguarded cells, so we return 4. ``` **Constraints:** `1 <= m, n <= 105` `2 <= m * n <= 105` `1 <= guards.length, walls.length <= 5 * 104` `2 <= guards.length + walls.length <= m * n` `guards[i].length == walls[j].length == 2` `0 <= rowi, rowj < m` `0 <= coli, colj < n` All the positions in `guards` and `walls` are **unique**.", + "public_test_cases": [ + { + "label": "Example 1", + "input": "m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]]", + "output": "7 " + }, + { + "label": "Example 2", + "input": "m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]]", + "output": "4 " + } + ], + "private_test_cases": [ + { + "input": [ + 59, + 58, + [ + [ + 42, + 5 + ], + [ + 25, + 53 + ], + [ + 16, + 50 + ], + [ + 11, + 5 + ], + [ + 48, + 54 + ], + [ + 25, + 1 + ], + [ + 38, + 1 + ], + [ + 54, + 52 + ], + [ + 7, + 7 + ], + [ + 14, + 46 + ], + [ + 34, + 3 + ], + [ + 1, + 36 + ], + [ + 52, + 34 + ], + [ + 29, + 37 + ], + [ + 9, + 16 + ], + [ + 23, + 36 + ], + [ + 35, + 28 + ], + [ + 22, + 0 + ], + [ + 54, + 17 + ], + [ + 41, + 13 + ], + [ + 8, + 10 + ], + [ + 10, + 13 + ], + [ + 20, + 45 + ], + [ + 54, + 47 + ], + [ + 7, + 51 + ], + [ + 47, + 50 + ] + ], + [ + [ + 27, + 4 + ], + [ + 38, + 50 + ], + [ + 6, + 51 + ], + [ + 4, + 27 + ], + [ + 32, + 9 + ], + [ + 23, + 34 + ], + [ + 38, + 4 + ], + [ + 10, + 24 + ], + [ + 25, + 25 + ], + [ + 5, + 55 + ], + [ + 19, + 54 + ], + [ + 56, + 36 + ], + [ + 22, + 46 + ], + [ + 37, + 32 + ], + [ + 50, + 47 + ], + [ + 46, + 28 + ], + [ + 39, + 25 + ], + [ + 23, + 14 + ], + [ + 34, + 14 + ], + [ + 45, + 14 + ], + [ + 54, + 38 + ], + [ + 1, + 7 + ], + [ + 55, + 45 + ], + [ + 42, + 27 + ], + [ + 57, + 21 + ], + [ + 8, + 34 + ] + ] + ], + "output": 1617 + }, + { + "input": [ + 64, + 66, + [ + [ + 6, + 12 + ], + [ + 52, + 52 + ], + [ + 1, + 58 + ], + [ + 47, + 28 + ], + [ + 37, + 39 + ], + [ + 33, + 29 + ], + [ + 4, + 2 + ], + [ + 41, + 51 + ], + [ + 19, + 48 + ], + [ + 38, + 55 + ], + [ + 63, + 48 + ], + [ + 49, + 3 + ], + [ + 35, + 25 + ], + [ + 15, + 16 + ], + [ + 30, + 41 + ], + [ + 20, + 18 + ], + [ + 51, + 45 + ], + [ + 49, + 27 + ], + [ + 32, + 47 + ], + [ + 22, + 18 + ], + [ + 0, + 46 + ], + [ + 25, + 45 + ], + [ + 27, + 17 + ], + [ + 62, + 45 + ], + [ + 19, + 22 + ], + [ + 53, + 48 + ], + [ + 57, + 12 + ], + [ + 43, + 25 + ], + [ + 29, + 63 + ], + [ + 39, + 55 + ] + ], + [ + [ + 9, + 38 + ], + [ + 58, + 52 + ], + [ + 18, + 24 + ], + [ + 59, + 53 + ] + ] + ], + "output": 1584 + }, + { + "input": [ + 40, + 8, + [ + [ + 34, + 4 + ], + [ + 3, + 7 + ], + [ + 0, + 2 + ], + [ + 10, + 0 + ], + [ + 18, + 4 + ], + [ + 26, + 5 + ], + [ + 7, + 1 + ], + [ + 39, + 5 + ], + [ + 37, + 5 + ], + [ + 2, + 4 + ], + [ + 33, + 7 + ], + [ + 26, + 1 + ], + [ + 13, + 1 + ], + [ + 26, + 7 + ], + [ + 6, + 7 + ], + [ + 31, + 6 + ], + [ + 31, + 3 + ], + [ + 3, + 2 + ], + [ + 9, + 0 + ], + [ + 5, + 5 + ], + [ + 38, + 2 + ], + [ + 15, + 6 + ], + [ + 21, + 1 + ] + ], + [ + [ + 3, + 4 + ], + [ + 22, + 5 + ], + [ + 8, + 0 + ], + [ + 27, + 7 + ], + [ + 2, + 5 + ], + [ + 24, + 5 + ], + [ + 38, + 4 + ], + [ + 38, + 7 + ], + [ + 29, + 4 + ], + [ + 29, + 1 + ], + [ + 20, + 1 + ], + [ + 34, + 0 + ], + [ + 23, + 0 + ], + [ + 12, + 3 + ], + [ + 3, + 0 + ], + [ + 17, + 2 + ], + [ + 30, + 5 + ], + [ + 24, + 1 + ], + [ + 35, + 7 + ], + [ + 39, + 7 + ], + [ + 14, + 2 + ], + [ + 4, + 7 + ], + [ + 28, + 1 + ], + [ + 10, + 4 + ], + [ + 1, + 1 + ], + [ + 24, + 0 + ], + [ + 33, + 6 + ], + [ + 13, + 3 + ], + [ + 38, + 5 + ] + ] + ], + "output": 29 + }, + { + "input": [ + 57, + 15, + [ + [ + 22, + 8 + ], + [ + 17, + 9 + ], + [ + 25, + 4 + ], + [ + 40, + 13 + ], + [ + 21, + 3 + ], + [ + 45, + 9 + ], + [ + 36, + 3 + ], + [ + 14, + 12 + ], + [ + 8, + 11 + ], + [ + 26, + 1 + ], + [ + 32, + 11 + ], + [ + 25, + 9 + ], + [ + 32, + 14 + ], + [ + 2, + 10 + ], + [ + 12, + 2 + ], + [ + 22, + 6 + ], + [ + 31, + 12 + ], + [ + 12, + 8 + ], + [ + 43, + 1 + ], + [ + 17, + 10 + ], + [ + 11, + 9 + ], + [ + 46, + 0 + ], + [ + 24, + 6 + ], + [ + 35, + 6 + ], + [ + 46, + 3 + ], + [ + 26, + 12 + ] + ], + [ + [ + 55, + 12 + ], + [ + 11, + 7 + ], + [ + 2, + 7 + ], + [ + 49, + 13 + ], + [ + 46, + 10 + ], + [ + 22, + 7 + ] + ] + ], + "output": 96 + }, + { + "input": [ + 54, + 7, + [ + [ + 12, + 2 + ] + ], + [ + [ + 47, + 2 + ], + [ + 44, + 3 + ] + ] + ], + "output": 323 + }, + { + "input": [ + 71, + 91, + [ + [ + 47, + 65 + ], + [ + 22, + 11 + ], + [ + 22, + 75 + ], + [ + 43, + 61 + ], + [ + 58, + 28 + ], + [ + 15, + 14 + ], + [ + 27, + 46 + ], + [ + 13, + 26 + ], + [ + 16, + 22 + ], + [ + 63, + 15 + ], + [ + 49, + 86 + ], + [ + 40, + 22 + ], + [ + 16, + 89 + ], + [ + 32, + 45 + ], + [ + 6, + 32 + ], + [ + 37, + 63 + ], + [ + 47, + 21 + ], + [ + 52, + 72 + ], + [ + 34, + 88 + ], + [ + 48, + 1 + ], + [ + 40, + 52 + ], + [ + 39, + 1 + ], + [ + 48, + 7 + ], + [ + 50, + 38 + ], + [ + 65, + 87 + ], + [ + 9, + 34 + ], + [ + 49, + 24 + ], + [ + 34, + 69 + ], + [ + 10, + 41 + ], + [ + 67, + 14 + ], + [ + 54, + 87 + ], + [ + 50, + 16 + ], + [ + 58, + 81 + ], + [ + 8, + 16 + ], + [ + 27, + 23 + ], + [ + 21, + 44 + ], + [ + 4, + 34 + ], + [ + 7, + 2 + ], + [ + 65, + 86 + ], + [ + 20, + 60 + ] + ], + [ + [ + 27, + 47 + ], + [ + 15, + 24 + ], + [ + 36, + 4 + ], + [ + 59, + 58 + ], + [ + 24, + 45 + ], + [ + 63, + 31 + ], + [ + 43, + 52 + ], + [ + 41, + 6 + ], + [ + 21, + 28 + ], + [ + 48, + 45 + ], + [ + 58, + 80 + ], + [ + 11, + 60 + ], + [ + 15, + 48 + ], + [ + 45, + 31 + ], + [ + 44, + 8 + ], + [ + 65, + 15 + ], + [ + 10, + 12 + ], + [ + 46, + 11 + ], + [ + 12, + 40 + ], + [ + 2, + 23 + ], + [ + 2, + 29 + ], + [ + 18, + 19 + ], + [ + 8, + 39 + ], + [ + 33, + 38 + ], + [ + 18, + 22 + ], + [ + 9, + 53 + ], + [ + 27, + 82 + ], + [ + 48, + 56 + ], + [ + 69, + 36 + ], + [ + 21, + 51 + ], + [ + 70, + 41 + ], + [ + 2, + 19 + ], + [ + 18, + 76 + ], + [ + 57, + 86 + ], + [ + 10, + 38 + ], + [ + 46, + 31 + ], + [ + 24, + 49 + ], + [ + 69, + 69 + ], + [ + 6, + 40 + ], + [ + 43, + 7 + ], + [ + 39, + 9 + ] + ] + ], + "output": 2961 + }, + { + "input": [ + 89, + 89, + [ + [ + 29, + 81 + ], + [ + 20, + 78 + ], + [ + 29, + 38 + ], + [ + 30, + 12 + ], + [ + 10, + 3 + ], + [ + 16, + 53 + ], + [ + 5, + 22 + ], + [ + 75, + 32 + ], + [ + 70, + 45 + ], + [ + 55, + 56 + ], + [ + 23, + 12 + ], + [ + 45, + 76 + ], + [ + 56, + 15 + ], + [ + 40, + 46 + ], + [ + 57, + 74 + ], + [ + 65, + 35 + ], + [ + 25, + 27 + ], + [ + 27, + 57 + ], + [ + 62, + 30 + ], + [ + 14, + 44 + ], + [ + 67, + 41 + ] + ], + [ + [ + 68, + 88 + ], + [ + 84, + 78 + ], + [ + 4, + 3 + ], + [ + 37, + 9 + ], + [ + 61, + 61 + ], + [ + 59, + 9 + ], + [ + 49, + 32 + ], + [ + 24, + 45 + ], + [ + 33, + 48 + ], + [ + 67, + 80 + ], + [ + 34, + 22 + ], + [ + 18, + 47 + ], + [ + 9, + 78 + ], + [ + 17, + 30 + ], + [ + 4, + 39 + ], + [ + 80, + 46 + ], + [ + 62, + 71 + ], + [ + 49, + 19 + ], + [ + 45, + 70 + ], + [ + 34, + 3 + ], + [ + 47, + 0 + ], + [ + 29, + 83 + ], + [ + 31, + 74 + ], + [ + 30, + 54 + ], + [ + 46, + 47 + ], + [ + 61, + 8 + ], + [ + 51, + 9 + ], + [ + 81, + 1 + ], + [ + 2, + 10 + ], + [ + 47, + 42 + ], + [ + 81, + 74 + ], + [ + 34, + 2 + ], + [ + 24, + 86 + ], + [ + 45, + 60 + ], + [ + 65, + 38 + ], + [ + 28, + 1 + ], + [ + 23, + 81 + ], + [ + 70, + 80 + ], + [ + 35, + 58 + ], + [ + 19, + 65 + ], + [ + 74, + 10 + ], + [ + 53, + 51 + ], + [ + 72, + 3 + ], + [ + 15, + 9 + ], + [ + 40, + 63 + ], + [ + 15, + 67 + ], + [ + 46, + 21 + ] + ] + ], + "output": 5165 + }, + { + "input": [ + 30, + 98, + [ + [ + 28, + 62 + ], + [ + 20, + 14 + ], + [ + 18, + 36 + ], + [ + 24, + 68 + ], + [ + 4, + 83 + ], + [ + 18, + 60 + ], + [ + 7, + 64 + ], + [ + 9, + 89 + ], + [ + 4, + 89 + ], + [ + 19, + 35 + ], + [ + 5, + 90 + ], + [ + 19, + 22 + ], + [ + 26, + 48 + ], + [ + 18, + 37 + ], + [ + 25, + 62 + ], + [ + 15, + 86 + ], + [ + 25, + 42 + ] + ], + [ + [ + 12, + 27 + ], + [ + 9, + 61 + ], + [ + 20, + 38 + ], + [ + 13, + 23 + ], + [ + 13, + 26 + ], + [ + 0, + 34 + ], + [ + 12, + 13 + ], + [ + 7, + 74 + ], + [ + 23, + 3 + ], + [ + 28, + 3 + ], + [ + 14, + 58 + ], + [ + 26, + 90 + ], + [ + 17, + 86 + ], + [ + 2, + 70 + ], + [ + 12, + 21 + ], + [ + 24, + 15 + ], + [ + 20, + 76 + ] + ] + ], + "output": 1637 + }, + { + "input": [ + 67, + 19, + [ + [ + 6, + 12 + ], + [ + 63, + 16 + ], + [ + 55, + 2 + ], + [ + 21, + 13 + ], + [ + 8, + 0 + ], + [ + 28, + 6 + ], + [ + 59, + 15 + ], + [ + 27, + 10 + ], + [ + 30, + 18 + ], + [ + 65, + 15 + ], + [ + 7, + 7 + ], + [ + 55, + 1 + ], + [ + 18, + 16 + ], + [ + 31, + 16 + ], + [ + 12, + 12 + ], + [ + 61, + 11 + ], + [ + 9, + 1 + ], + [ + 19, + 5 + ], + [ + 33, + 7 + ], + [ + 16, + 0 + ], + [ + 41, + 17 + ], + [ + 38, + 0 + ], + [ + 15, + 4 + ], + [ + 39, + 1 + ], + [ + 49, + 3 + ], + [ + 38, + 3 + ], + [ + 48, + 16 + ], + [ + 39, + 13 + ], + [ + 16, + 15 + ], + [ + 36, + 2 + ], + [ + 7, + 18 + ], + [ + 12, + 8 + ], + [ + 23, + 8 + ], + [ + 41, + 1 + ], + [ + 19, + 10 + ], + [ + 44, + 9 + ], + [ + 48, + 6 + ], + [ + 11, + 15 + ], + [ + 63, + 1 + ] + ], + [ + [ + 22, + 5 + ], + [ + 65, + 0 + ], + [ + 66, + 5 + ], + [ + 33, + 11 + ], + [ + 51, + 16 + ], + [ + 44, + 14 + ], + [ + 11, + 17 + ], + [ + 7, + 4 + ], + [ + 57, + 17 + ], + [ + 38, + 13 + ], + [ + 22, + 4 + ], + [ + 63, + 15 + ], + [ + 20, + 16 + ], + [ + 53, + 16 + ], + [ + 58, + 6 + ], + [ + 39, + 17 + ], + [ + 37, + 11 + ], + [ + 17, + 5 + ], + [ + 3, + 15 + ], + [ + 8, + 5 + ], + [ + 57, + 1 + ], + [ + 65, + 11 + ], + [ + 57, + 13 + ], + [ + 33, + 13 + ], + [ + 18, + 9 + ], + [ + 64, + 15 + ], + [ + 52, + 1 + ], + [ + 60, + 8 + ], + [ + 45, + 17 + ], + [ + 9, + 0 + ], + [ + 3, + 17 + ], + [ + 9, + 6 + ], + [ + 51, + 11 + ], + [ + 35, + 3 + ], + [ + 15, + 0 + ], + [ + 54, + 1 + ] + ] + ], + "output": 240 + }, + { + "input": [ + 97, + 4, + [ + [ + 80, + 1 + ], + [ + 4, + 0 + ], + [ + 93, + 1 + ], + [ + 61, + 0 + ], + [ + 83, + 0 + ], + [ + 92, + 3 + ], + [ + 81, + 2 + ], + [ + 29, + 1 + ], + [ + 54, + 0 + ], + [ + 67, + 0 + ], + [ + 37, + 2 + ], + [ + 70, + 2 + ], + [ + 80, + 0 + ], + [ + 36, + 3 + ], + [ + 27, + 3 + ], + [ + 52, + 2 + ], + [ + 74, + 2 + ], + [ + 32, + 2 + ], + [ + 35, + 1 + ], + [ + 18, + 0 + ], + [ + 82, + 3 + ], + [ + 71, + 3 + ], + [ + 18, + 3 + ], + [ + 22, + 3 + ], + [ + 91, + 2 + ], + [ + 70, + 1 + ], + [ + 94, + 1 + ], + [ + 37, + 1 + ], + [ + 52, + 1 + ], + [ + 28, + 1 + ], + [ + 8, + 1 + ], + [ + 33, + 0 + ], + [ + 46, + 0 + ], + [ + 35, + 3 + ], + [ + 15, + 0 + ], + [ + 81, + 0 + ], + [ + 86, + 2 + ] + ], + [ + [ + 45, + 1 + ], + [ + 91, + 1 + ], + [ + 92, + 0 + ], + [ + 42, + 2 + ], + [ + 94, + 3 + ], + [ + 8, + 3 + ], + [ + 41, + 3 + ], + [ + 68, + 2 + ], + [ + 90, + 2 + ], + [ + 95, + 1 + ], + [ + 7, + 1 + ], + [ + 40, + 1 + ], + [ + 21, + 0 + ], + [ + 18, + 1 + ], + [ + 20, + 1 + ], + [ + 31, + 1 + ], + [ + 12, + 0 + ], + [ + 47, + 0 + ], + [ + 69, + 0 + ], + [ + 69, + 3 + ], + [ + 85, + 2 + ], + [ + 75, + 1 + ], + [ + 46, + 1 + ], + [ + 16, + 3 + ], + [ + 49, + 3 + ], + [ + 29, + 3 + ], + [ + 31, + 0 + ], + [ + 45, + 2 + ], + [ + 14, + 2 + ], + [ + 3, + 2 + ], + [ + 4, + 1 + ], + [ + 5, + 2 + ], + [ + 43, + 1 + ], + [ + 11, + 0 + ], + [ + 76, + 1 + ], + [ + 66, + 0 + ], + [ + 68, + 0 + ], + [ + 68, + 3 + ], + [ + 38, + 2 + ], + [ + 40, + 2 + ], + [ + 84, + 2 + ] + ] + ], + "output": 70 + } + ], + "haskell_template": "countUnguarded :: Int -> Int -> [[Int]] -> [[Int]] -> Int\ncountUnguarded m n guards walls ", + "ocaml_template": "let countUnguarded (m: int) (n: int) (guards: int list list) (walls: int list list) : int = ", + "scala_template": "def countUnguarded(m: Int,n: Int,guards: List[List[Int]],walls: List[List[Int]]): Int = { \n \n}", + "java_template": "public static int countUnguarded(int m, int n, List> guards, List> walls) {\n\n}", + "python_template": "class Solution(object):\n def countUnguarded(self, m, n, guards, walls):\n \"\"\"\n :type m: int\n :type n: int\n :type guards: List[List[int]]\n :type walls: List[List[int]]\n :rtype: int\n \"\"\"\n " +} \ No newline at end of file diff --git a/count_unguarded_cells_in_the_grid/ocaml_tests/main.ml b/count_unguarded_cells_in_the_grid/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..d4751f3b84fdd76cd96daf15b38bdb9e9b61abfc --- /dev/null +++ b/count_unguarded_cells_in_the_grid/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal 7 (countUnguarded 4 6 [[0;0];[1;1];[2;3]] [[0;1];[2;2];[1;4]]) + +let test2 _ = assert_equal 4 (countUnguarded 3 3 [[1;1]] [[0;1];[1;0];[2;1];[1;2]]) + + + (* Grouping test cases *) + let suite = "Test Suite for countUnguarded" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/count_unguarded_cells_in_the_grid/scala_tests/MySuite.scala b/count_unguarded_cells_in_the_grid/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..01b5f75d02bfec6ea32e439e5d2f773f141b34ac --- /dev/null +++ b/count_unguarded_cells_in_the_grid/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.countUnguarded(4,6,List(List(0,0),List(1,1),List(2,3)),List(List(0,1),List(2,2),List(1,4))), 7) + } + + test("test2") { + assertEquals(Main.countUnguarded(3,3,List(List(1,1)),List(List(0,1),List(1,0),List(2,1),List(1,2))), 4) + } + +} diff --git a/count_unreachable_pairs_of_nodes_in_an_undirected_graph/haskell_tests/Main.hs b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..f1783f004ae7910d3c3e1f3294142c31292a10ed --- /dev/null +++ b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/haskell_tests/Main.hs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4bed2626d3b40d27fb4e530060800812b16d269ad6a9eaf43db818a057a83d0a +size 30964688 diff --git a/count_unreachable_pairs_of_nodes_in_an_undirected_graph/java_tests/Main.java b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..59f3256976d3867ba8a83da3ba80bf4f31d1fb3b --- /dev/null +++ b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(0, countPairs(3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(1,2)))))); +} +@Test +public void test2() { + assertEquals(14, countPairs(7, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(0,5)),new ArrayList<>(Arrays.asList(2,4)),new ArrayList<>(Arrays.asList(1,6)),new ArrayList<>(Arrays.asList(5,4)))))); +} + +} diff --git a/count_unreachable_pairs_of_nodes_in_an_undirected_graph/meta.json b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..1f78cb1a43281d9857617c3ec268affaa66af6fc --- /dev/null +++ b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/meta.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4d84dc62332a933cc05b947281440e411a662a2852d199b7f813a542ef88a25 +size 105484709 diff --git a/count_unreachable_pairs_of_nodes_in_an_undirected_graph/ocaml_tests/main.ml b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..8d3d2f0b676dea4f8949d70308f33d4f9f210f0c --- /dev/null +++ b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/ocaml_tests/main.ml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0034496c8035f20349a6835ce477f52814560a5b6e066876ebd7ede1125996a0 +size 15482623 diff --git a/count_unreachable_pairs_of_nodes_in_an_undirected_graph/scala_tests/MySuite.scala b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..97b9de74799f876d653ec65ce453cb9d5bb97751 --- /dev/null +++ b/count_unreachable_pairs_of_nodes_in_an_undirected_graph/scala_tests/MySuite.scala @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d08630324c4f10be2e4f6d19576beb25928ed083f7c33d1535937e556a8058c7 +size 19482427 diff --git a/count_valid_paths_in_a_tree/java_tests/Main.java b/count_valid_paths_in_a_tree/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..6a624e1796cc1124117c8611415255ce8dd0e669 --- /dev/null +++ b/count_valid_paths_in_a_tree/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(4, countPaths(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(2,4)),new ArrayList<>(Arrays.asList(2,5)))))); +} +@Test +public void test2() { + assertEquals(6, countPaths(6, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(2,4)),new ArrayList<>(Arrays.asList(3,5)),new ArrayList<>(Arrays.asList(3,6)))))); +} + +} diff --git a/count_ways_to_build_good_strings/.DS_Store b/count_ways_to_build_good_strings/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..db496e9e51437e4911182f6c76045fcca3cf1873 Binary files /dev/null and b/count_ways_to_build_good_strings/.DS_Store differ diff --git a/count_ways_to_build_good_strings/haskell_tests/Main.hs b/count_ways_to_build_good_strings/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..0f9de1e9956f7015ed4c6bdb2aedf7bda3b2e178 --- /dev/null +++ b/count_ways_to_build_good_strings/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (countGoodStrings 3 3 1 1)," 8 (countGoodStrings 3 3 1 1)) + +test2 :: Test +test2 = TestCase (assertEqual "for (countGoodStrings 2 3 1 2)," 5 (countGoodStrings 2 3 1 2)) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/count_ways_to_build_good_strings/java_tests/Main.java b/count_ways_to_build_good_strings/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..4b67f89cfc863493b112d187a05cf98d28d6937b --- /dev/null +++ b/count_ways_to_build_good_strings/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(8, countGoodStrings(3, 3, 1, 1)); +} +@Test +public void test2() { + assertEquals(5, countGoodStrings(2, 3, 1, 2)); +} + +} diff --git a/count_ways_to_build_good_strings/meta.json b/count_ways_to_build_good_strings/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..8e3e838fe2ac39c34c760096de4feb5d9ccbe446 --- /dev/null +++ b/count_ways_to_build_good_strings/meta.json @@ -0,0 +1,117 @@ +{ + "id": 2562, + "name": "count_ways_to_build_good_strings", + "difficulty": "Medium", + "link": "https://leetcode.com/problems/count-ways-to-build-good-strings/", + "date": "1667001600000", + "task_description": "Given the integers `zero`, `one`, `low`, and `high`, we can construct a string by starting with an empty string, and then at each step perform either of the following: Append the character `'0'` `zero` times. Append the character `'1'` `one` times. This can be performed any number of times. A **good** string is a string constructed by the above process having a **length** between `low` and `high` (**inclusive**). Return _the number of **different** good strings that can be constructed satisfying these properties._ Since the answer can be large, return it **modulo** `109 + 7`. **Example 1:** ``` **Input:** low = 3, high = 3, zero = 1, one = 1 **Output:** 8 **Explanation:** One possible valid good string is \"011\". It can be constructed as follows: \"\" -> \"0\" -> \"01\" -> \"011\". All binary strings from \"000\" to \"111\" are good strings in this example. ``` **Example 2:** ``` **Input:** low = 2, high = 3, zero = 1, one = 2 **Output:** 5 **Explanation:** The good strings are \"00\", \"11\", \"000\", \"110\", and \"011\". ``` **Constraints:** `1 <= low <= high <= 105` `1 <= zero, one <= low`", + "public_test_cases": [ + { + "label": "Example 1", + "input": "low = 3, high = 3, zero = 1, one = 1", + "output": "8 " + }, + { + "label": "Example 2", + "input": "low = 2, high = 3, zero = 1, one = 2", + "output": "5 " + } + ], + "private_test_cases": [ + { + "input": [ + 43516, + 53594, + 36914, + 8563 + ], + "output": 3 + }, + { + "input": [ + 22795, + 79620, + 5950, + 17821 + ], + "output": 271 + }, + { + "input": [ + 44226, + 61537, + 1112, + 5820 + ], + "output": 6386055 + }, + { + "input": [ + 54729, + 88024, + 33857, + 3651 + ], + "output": 165 + }, + { + "input": [ + 72028, + 86808, + 34039, + 62250 + ], + "output": 0 + }, + { + "input": [ + 14697, + 66644, + 7822, + 14370 + ], + "output": 110 + }, + { + "input": [ + 77737, + 96641, + 12337, + 17682 + ], + "output": 70 + }, + { + "input": [ + 33570, + 41074, + 25499, + 24258 + ], + "output": 0 + }, + { + "input": [ + 92099, + 92587, + 57439, + 73995 + ], + "output": 0 + }, + { + "input": [ + 59859, + 94179, + 21463, + 2717 + ], + "output": 2573 + } + ], + "haskell_template": "countGoodStrings :: Int -> Int -> Int -> Int -> Int\ncountGoodStrings low high zero one ", + "ocaml_template": "let countGoodStrings (low: int) (high: int) (zero: int) (one: int) : int = ", + "scala_template": "def countGoodStrings(low: Int,high: Int,zero: Int,one: Int): Int = { \n \n}", + "java_template": "public static int countGoodStrings(int low, int high, int zero, int one) {\n\n}", + "python_template": "class Solution(object):\n def countGoodStrings(self, low, high, zero, one):\n \"\"\"\n :type low: int\n :type high: int\n :type zero: int\n :type one: int\n :rtype: int\n \"\"\"\n " +} \ No newline at end of file diff --git a/count_ways_to_build_good_strings/ocaml_tests/main.ml b/count_ways_to_build_good_strings/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..77d61d68e8fcb18def1b95862f5bbbfbcd49e199 --- /dev/null +++ b/count_ways_to_build_good_strings/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal 8 (countGoodStrings 3 3 1 1) + +let test2 _ = assert_equal 5 (countGoodStrings 2 3 1 2) + + + (* Grouping test cases *) + let suite = "Test Suite for countGoodStrings" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/count_ways_to_build_good_strings/scala_tests/MySuite.scala b/count_ways_to_build_good_strings/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..2c9f82dc010f63521400fc3e6bcb0622b22dbbb0 --- /dev/null +++ b/count_ways_to_build_good_strings/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.countGoodStrings(3,3,1,1), 8) + } + + test("test2") { + assertEquals(Main.countGoodStrings(2,3,1,2), 5) + } + +} diff --git a/count_ways_to_group_overlapping_ranges/.DS_Store b/count_ways_to_group_overlapping_ranges/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2fb4f0fa4b327051171674df64aa9657f4a444be Binary files /dev/null and b/count_ways_to_group_overlapping_ranges/.DS_Store differ diff --git a/count_ways_to_group_overlapping_ranges/haskell_tests/Main.hs b/count_ways_to_group_overlapping_ranges/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..a5fe0926f2a3ceb496cd36c3d0171049b3c96a6b --- /dev/null +++ b/count_ways_to_group_overlapping_ranges/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (countWays [[6,10],[5,15]])," 2 (countWays [[6,10],[5,15]])) + +test2 :: Test +test2 = TestCase (assertEqual "for (countWays [[1,3],[10,20],[2,5],[4,8]])," 4 (countWays [[1,3],[10,20],[2,5],[4,8]])) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/count_ways_to_group_overlapping_ranges/java_tests/Main.java b/count_ways_to_group_overlapping_ranges/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..f915f376a83a1c45b067415e35c05d87f1244b05 --- /dev/null +++ b/count_ways_to_group_overlapping_ranges/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(2, countWays(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(6,10)),new ArrayList<>(Arrays.asList(5,15)))))); +} +@Test +public void test2() { + assertEquals(4, countWays(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(10,20)),new ArrayList<>(Arrays.asList(2,5)),new ArrayList<>(Arrays.asList(4,8)))))); +} + +} diff --git a/count_ways_to_group_overlapping_ranges/meta.json b/count_ways_to_group_overlapping_ranges/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..4924f2602e59cf9cc053efe2e02b7252db9cf6d3 --- /dev/null +++ b/count_ways_to_group_overlapping_ranges/meta.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c45ef151455e14c4ff6bf7c3b9b2e0e2a6b82af112a48c330f54eb720ba14000 +size 47568545 diff --git a/count_ways_to_group_overlapping_ranges/ocaml_tests/main.ml b/count_ways_to_group_overlapping_ranges/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..f074f948efbc338ce01185ee2bfee8fd04b6a976 --- /dev/null +++ b/count_ways_to_group_overlapping_ranges/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal 2 (countWays [[6;10];[5;15]]) + +let test2 _ = assert_equal 4 (countWays [[1;3];[10;20];[2;5];[4;8]]) + + + (* Grouping test cases *) + let suite = "Test Suite for countWays" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/count_ways_to_group_overlapping_ranges/scala_tests/MySuite.scala b/count_ways_to_group_overlapping_ranges/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..4ea235f398a88c59b50624d55a20837804ee5a3b --- /dev/null +++ b/count_ways_to_group_overlapping_ranges/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.countWays(List(List(6,10),List(5,15))), 2) + } + + test("test2") { + assertEquals(Main.countWays(List(List(1,3),List(10,20),List(2,5),List(4,8))), 4) + } + +} diff --git a/count_words_obtained_after_adding_a_letter/.DS_Store b/count_words_obtained_after_adding_a_letter/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..96d7616c48ddec1418cf9a3299ccaa1d5e8ffe0e Binary files /dev/null and b/count_words_obtained_after_adding_a_letter/.DS_Store differ diff --git a/count_words_obtained_after_adding_a_letter/haskell_tests/Main.hs b/count_words_obtained_after_adding_a_letter/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..2230524634d970e250bea2b36a4bd11739cd3e2e --- /dev/null +++ b/count_words_obtained_after_adding_a_letter/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (wordCount [ \"ant \", \"act \", \"tack \"] [ \"tack \", \"act \", \"acti \"])," 2 (wordCount ["ant","act","tack"] ["tack","act","acti"])) + +test2 :: Test +test2 = TestCase (assertEqual "for (wordCount [ \"ab \", \"a \"] [ \"abc \", \"abcd \"])," 1 (wordCount ["ab","a"] ["abc","abcd"])) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/count_words_obtained_after_adding_a_letter/java_tests/Main.java b/count_words_obtained_after_adding_a_letter/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..2d76e74932650db3276837b7273ef3a47752f18c --- /dev/null +++ b/count_words_obtained_after_adding_a_letter/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(2, wordCount(new ArrayList<>(Arrays.asList("ant","act","tack")), new ArrayList<>(Arrays.asList("tack","act","acti")))); +} +@Test +public void test2() { + assertEquals(1, wordCount(new ArrayList<>(Arrays.asList("ab","a")), new ArrayList<>(Arrays.asList("abc","abcd")))); +} + +} diff --git a/count_words_obtained_after_adding_a_letter/meta.json b/count_words_obtained_after_adding_a_letter/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..bab39c15f434cbb846bb0d2a431bcf80727e4e3c --- /dev/null +++ b/count_words_obtained_after_adding_a_letter/meta.json @@ -0,0 +1,26 @@ +{ + "id": 2256, + "name": "count_words_obtained_after_adding_a_letter", + "difficulty": "Medium", + "link": "https://leetcode.com/problems/count-words-obtained-after-adding-a-letter/", + "date": "1641081600000", + "task_description": "You are given two **0-indexed** arrays of strings `startWords` and `targetWords`. Each string consists of **lowercase English letters** only. For each string in `targetWords`, check if it is possible to choose a string from `startWords` and perform a **conversion operation** on it to be equal to that from `targetWords`. The **conversion operation** is described in the following two steps: **Append** any lowercase letter that is **not present** in the string to its end. For example, if the string is `\"abc\"`, the letters `'d'`, `'e'`, or `'y'` can be added to it, but not `'a'`. If `'d'` is added, the resulting string will be `\"abcd\"`. **Rearrange** the letters of the new string in **any** arbitrary order. For example, `\"abcd\"` can be rearranged to `\"acbd\"`, `\"bacd\"`, `\"cbda\"`, and so on. Note that it can also be rearranged to `\"abcd\"` itself. Return _the **number of strings** in _`targetWords`_ that can be obtained by performing the operations on **any** string of _`startWords`. **Note** that you will only be verifying if the string in `targetWords` can be obtained from a string in `startWords` by performing the operations. The strings in `startWords` **do not** actually change during this process. **Example 1:** ``` **Input:** startWords = [\"ant\",\"act\",\"tack\"], targetWords = [\"tack\",\"act\",\"acti\"] **Output:** 2 **Explanation:** - In order to form targetWords[0] = \"tack\", we use startWords[1] = \"act\", append 'k' to it, and rearrange \"actk\" to \"tack\". - There is no string in startWords that can be used to obtain targetWords[1] = \"act\". Note that \"act\" does exist in startWords, but we **must** append one letter to the string before rearranging it. - In order to form targetWords[2] = \"acti\", we use startWords[1] = \"act\", append 'i' to it, and rearrange \"acti\" to \"acti\" itself. ``` **Example 2:** ``` **Input:** startWords = [\"ab\",\"a\"], targetWords = [\"abc\",\"abcd\"] **Output:** 1 **Explanation:** - In order to form targetWords[0] = \"abc\", we use startWords[0] = \"ab\", add 'c' to it, and rearrange it to \"abc\". - There is no string in startWords that can be used to obtain targetWords[1] = \"abcd\". ``` **Constraints:** `1 <= startWords.length, targetWords.length <= 5 * 104` `1 <= startWords[i].length, targetWords[j].length <= 26` Each string of `startWords` and `targetWords` consists of lowercase English letters only. No letter occurs more than once in any string of `startWords` or `targetWords`.", + "public_test_cases": [ + { + "label": "Example 1", + "input": "startWords = [\"ant\",\"act\",\"tack\"], targetWords = [\"tack\",\"act\",\"acti\"]", + "output": "2 " + }, + { + "label": "Example 2", + "input": "startWords = [\"ab\",\"a\"], targetWords = [\"abc\",\"abcd\"]", + "output": "1 " + } + ], + "private_test_cases": [], + "haskell_template": "wordCount :: [String] -> [String] -> Int\nwordCount startWords targetWords ", + "ocaml_template": "let wordCount (startWords: string list) (targetWords: string list) : int = ", + "scala_template": "def wordCount(startWords: List[String],targetWords: List[String]): Int = { \n \n}", + "java_template": "public static int wordCount(List startWords, List targetWords) {\n\n}", + "python_template": "class Solution(object):\n def wordCount(self, startWords, targetWords):\n \"\"\"\n :type startWords: List[str]\n :type targetWords: List[str]\n :rtype: int\n \"\"\"\n " +} \ No newline at end of file diff --git a/count_words_obtained_after_adding_a_letter/ocaml_tests/main.ml b/count_words_obtained_after_adding_a_letter/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..76ebc71a72dbd75316cd4aaf6ae43dfdd2b3f7c4 --- /dev/null +++ b/count_words_obtained_after_adding_a_letter/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal 2 (wordCount ["ant";"act";"tack"] ["tack";"act";"acti"]) + +let test2 _ = assert_equal 1 (wordCount ["ab";"a"] ["abc";"abcd"]) + + + (* Grouping test cases *) + let suite = "Test Suite for wordCount" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/count_words_obtained_after_adding_a_letter/scala_tests/MySuite.scala b/count_words_obtained_after_adding_a_letter/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..e3e75b667444b40f2f1c1938ada3e81e4c60444b --- /dev/null +++ b/count_words_obtained_after_adding_a_letter/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.wordCount(List("ant","act","tack"),List("tack","act","acti")), 2) + } + + test("test2") { + assertEquals(Main.wordCount(List("ab","a"),List("abc","abcd")), 1) + } + +} diff --git a/count_zero_request_servers/haskell_tests/Main.hs b/count_zero_request_servers/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..aff522a5c3ac8e7fc9f42ae3668711697ad6bf94 --- /dev/null +++ b/count_zero_request_servers/haskell_tests/Main.hs @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03613e04bcb7cfbbe2af922d150bafe8b405ed8d1f6183e05891a9846912a4df +size 22255905 diff --git a/count_zero_request_servers/java_tests/Main.java b/count_zero_request_servers/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..bf66c5d28b9dbcb3347201d9f1ac819a6a003325 --- /dev/null +++ b/count_zero_request_servers/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(new ArrayList<>(Arrays.asList(1,2)), countServers(3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(2,6)),new ArrayList<>(Arrays.asList(1,5)))), 5, new ArrayList<>(Arrays.asList(10,11)))); +} +@Test +public void test2() { + assertEquals(new ArrayList<>(Arrays.asList(0,1)), countServers(3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,4)),new ArrayList<>(Arrays.asList(2,1)),new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(3,1)))), 2, new ArrayList<>(Arrays.asList(3,4)))); +} + +} diff --git a/count_zero_request_servers/meta.json b/count_zero_request_servers/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..0e4f179cc948b6e9f03842e22dc084d2e225bb8b --- /dev/null +++ b/count_zero_request_servers/meta.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f246dde58ebed5b34fb5ed4b64c144bd03d73f0c19e68bfad1be0e45eab3ea8 +size 65688202 diff --git a/count_zero_request_servers/ocaml_tests/main.ml b/count_zero_request_servers/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..0315b622ec4d0d7fc4a937ec33ec49ee02dacfc1 --- /dev/null +++ b/count_zero_request_servers/ocaml_tests/main.ml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78a861dfef73b9fe7a0b979e83984e983204f1485ab438466a8464687b661b40 +size 12018501 diff --git a/count_zero_request_servers/scala_tests/MySuite.scala b/count_zero_request_servers/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..be2f8c2ee1572076a5616a203eac85b63901a3ec --- /dev/null +++ b/count_zero_request_servers/scala_tests/MySuite.scala @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad10a84c44e53d1df36dd92df6c1f1019a27759228ebc9488444d29fc49cd942 +size 13915553 diff --git a/counting_words_with_a_given_prefix/.DS_Store b/counting_words_with_a_given_prefix/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b39181c818b14bd1617b3f067856c7c9f892d258 Binary files /dev/null and b/counting_words_with_a_given_prefix/.DS_Store differ diff --git a/counting_words_with_a_given_prefix/haskell_tests/Main.hs b/counting_words_with_a_given_prefix/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..af67c5947d925c845dd3d3785c10ca49210a7a68 --- /dev/null +++ b/counting_words_with_a_given_prefix/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (prefixCount [ \"pay \", \" at tention \", \"practice \", \" at tend \"] \"at \")," 2 (prefixCount ["pay"," at tention","practice"," at tend"] "at")) + +test2 :: Test +test2 = TestCase (assertEqual "for (prefixCount [ \"leetcode \", \"win \", \"loops \", \"success \"] \"code \")," 0 (prefixCount ["leetcode","win","loops","success"] "code")) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/counting_words_with_a_given_prefix/java_tests/Main.java b/counting_words_with_a_given_prefix/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..fe6449746760b5a5abd0561a2062fdcb5590994e --- /dev/null +++ b/counting_words_with_a_given_prefix/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(2, prefixCount(new ArrayList<>(Arrays.asList("pay"," at tention","practice"," at tend")), "at")); +} +@Test +public void test2() { + assertEquals(0, prefixCount(new ArrayList<>(Arrays.asList("leetcode","win","loops","success")), "code")); +} + +} diff --git a/counting_words_with_a_given_prefix/meta.json b/counting_words_with_a_given_prefix/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..a24a9b7c70138baf72afa2be0065f547a0465967 --- /dev/null +++ b/counting_words_with_a_given_prefix/meta.json @@ -0,0 +1,625 @@ +{ + "id": 2292, + "name": "counting_words_with_a_given_prefix", + "difficulty": "Easy", + "link": "https://leetcode.com/problems/counting-words-with-a-given-prefix/", + "date": "1645315200000", + "task_description": "You are given an array of strings `words` and a string `pref`. Return _the number of strings in _`words`_ that contain _`pref`_ as a **prefix**_. A **prefix** of a string `s` is any leading contiguous substring of `s`. **Example 1:** ``` **Input:** words = [\"pay\",\"**at**tention\",\"practice\",\"**at**tend\"], `pref `= \"at\" **Output:** 2 **Explanation:** The 2 strings that contain \"at\" as a prefix are: \"**at**tention\" and \"**at**tend\". ``` **Example 2:** ``` **Input:** words = [\"leetcode\",\"win\",\"loops\",\"success\"], `pref `= \"code\" **Output:** 0 **Explanation:** There are no strings that contain \"code\" as a prefix. ``` **Constraints:** `1 <= words.length <= 100` `1 <= words[i].length, pref.length <= 100` `words[i]` and `pref` consist of lowercase English letters.", + "public_test_cases": [ + { + "label": "Example 1", + "input": "words = [\"pay\",\" at tention\",\"practice\",\" at tend\"], pref = \"at\"", + "output": "2 " + }, + { + "label": "Example 2", + "input": "words = [\"leetcode\",\"win\",\"loops\",\"success\"], pref = \"code\"", + "output": "0 " + } + ], + "private_test_cases": [ + { + "input": [ + [ + "areelhzwwfib", + "okjyaddpudwnathmfivjfhdhwisjkzji", + "uhtlifquxtwyoekuizzfhgtinttuylfjxpgubvbibsjerlpeverdxrmnuapdnwxssxvmwoswicxebniujtsrvykrjprdvhg", + "vjlmcqvodzkc", + "tunrnoazkqiojaesevvysbyvxppftmrmifelpkkpdflcsmwhpvdnkzwojkdkzjtncsrrgdizaugocmlboggd", + "zmpjqdjmpsmieijdblicagjtvfkrnheltzebhozaoyglcpcuuzghydtvtncmxhskjxgzcmef", + "mpqvquwxbjsrbhwweuuzxupzsiavolclqbjmmenfvrwppeohuklijjrsyfacaqljqsmt", + "zmpkieitzixiznidatflckkfbkoalurwisakvjl", + "qaiycridyxruraqirjkimoup", + "clzimkytyabronuaetuxsprikvclm", + "cqmdqahpziypvghmwnpwdjkldkxndiojfdycbhlxkxuyqdcjajwnumutrvyserwcddjjcicpxhowuokmmykvpcjghbperns", + "bizmbjlng", + "pmunkheivawafwzsracr", + "emzc", + "tocxx", + "shsucqdzpynwrvxoktusfmmhzitoydxdmkzpaqvkejqlmvazhblqzzjvspwnneysindiblqyxrlsktrpmulvjfoztrymvtoohk", + "eocjerwldjnamitmwajweailoqvpyzuavzuafolqxbehkesbgkzklwwcjmdxxytwdhlhdjsynaexyojoozfccimxsotyceh", + "pvvmprqnbalzjdxzqfmcvgrdhsx", + "ptvujlujetmcl", + "abeccxkndqnxsxfpvb", + "wlcbgbvffznhajveuaggdbe", + "mjgzaxrbxqjheioqmbnsuutykajasmglmafjllfg", + "akckfdtpumijpmzeirfidweozwdfajvvbvqellevfrqvarxrrgorsufhsiagylmbsldojrbhtivmuthijvsfqfdp", + "sutuisinxzhotswuydvjsxvuzwtzuqfvirjytnnvxgjregf", + "ufxjzhjhobnybzdpnhrc", + "jorvnyojqfstmvaxqvdzxknvceepldypsoousfefcidkbh", + "innkjimkozxtohaherycnvxyyxawjgkrjtwgsbdmkkccuaubeagtrtkaipefcfbwyrmmljnladigwvxhnfhdopbcabbugx", + "feuzvudcgissyqsebtbbuemzhbqsipptlkccjlrozdpwdlgxahsweraaajxfxbyskaovsiuturesf", + "ysvwkjxgnzuepqkklvdlatysmqcewmcdxspeduixsjnnehochlltewkymispczfqdxehzuktpontsibzmuotycvxjlluihtahisd", + "htovsaaoggndtuymppjyrrshbfjmqatnpqncuiqewhxqanuiejtiybvlpnaootzzdylhobhyryraiyqxzwhhatpqudhzqdmqa", + "izdkqpvfldbbnatflfossmrapporuqyrypys", + "yazhqbvqvbhrgb", + "nymhfjpxkgebvrgkkownziqmiwkqelhlflhkouirjfmbptgscivrcmhkzwwqxjillumbrtcztjectyeurrxztbarjerpudanshei", + "bngytmuzarbcxtnxgqitashqauzezmdpjqtjvhkxykpqqjinfjtdlcegmpvxylgrtksh", + "hjpfljpdpaosymllzbgxrgjhkih", + "vusnqubjzfhlbgvtnrthwlerofiipukvnzwbxpmeunzsbkoqclnkxxsxgizbkmiagmm", + "zevruhhkfmiagyuvxxrcumdlsaacymwztlhiwgkvwzgdqubdzjqkqxpcatpuavmxugwgywlvigpjtv", + "lacvcmwmxjfmhgjrosihvfchyqxldp", + "iofiianqwflpmubhmqskd", + "pvcqhxaswsnueajebvwnzxfoqlrvjrmnkewanhwpc", + "pxkdtnymsvqnnqvaovjoxrgebmnzrfdypxez", + "iupjubzkeuahkbgzbaitzazqlxbaxufvkaywfefdvixucbp", + "trbvkiima", + "bqlrlgxsqzlldhzbcxgakdhd", + "qbejywljsslqddeuvyturypuyebdgkz", + "tdxyqfxxfbrbhrr", + "dbry", + "idtkfifaonhxnfyiwgmusedzzvcmjhxhyxjrtcdzztem", + "dkmzhvdmfzfomclxomdhzdxvramtzfdwdnssgyjrxbyxoemcwslxrzbnuj", + "uujvqaiuifekfriexonmrcf", + "xdmsdynzflitfcewqinppbnkxeibochpvjcfvlhnajtktvhjvnfxzunkteuxqfbsljyljddmuhvxrxqwxautubfjbl", + "fmopaphscgbstwttbputnlhqxrlxzhgdvaxfecnfywuxgddrnxfoqtussrjzjlataitgfngsqrewntkvvrxbbfpbksbtnhsd", + "odtkgqdfqqyerhahvfarafvilypzotfajwbfvfahlzvpcarydssjqfkluvvmlhbeafddpfbkwqhnwnavu", + "iqllydvsytcqslwqycjujmilrlufrntrkuduhpfknxsdpkfbnpsakpmzwylswvrbukazzkvlaamgpfwcgmdhimpaeq", + "juarrxdjyvnpwxanzp", + "hzsgxfeegqczilffttentaaprfogjaonbvojbyrytjepvvitvfkylassactcruqsfhqadhtkpdvmgi", + "jkybmudfgrphvuqnhvvcbrpkmkoansifpuabbcsrzpgokzub", + "yvzkypegsbffyjmkcmseqzlytpilmsdzmomhsntfojwgeonmvdpcrrxk" + ], + "\"hzwpplakf\"" + ], + "output": 0 + }, + { + "input": [ + [ + "kajdfarsyxu", + "wpdrghafywjezfehcjhcpgqywbncdehmykzmcxdcfygggkyrfybnekykfcxrcnq", + "blelqcrujif", + "toopntnsnsxtzrdtlcpshtrstaeblbqoxvrlmjfjew", + "egafoyuyqzriobzdxbalzvelcqejpdkkfxldacicfwxaqgzsexmyfxvpdqzqupfiktk", + "hlgltrxusuhisakrum", + "bgkjamhfrhrmhsiqlhbl", + "anukwgcnryjmveerzvxxxzeouxesfpkyiagnrrwlmcvfbsqoqgsudutpdiljvk", + "wilylanywbrjaqodfdshttsqckxautxvcsnruym", + "wnntznkvaqtoubkelvkbgswmnibpsnxgcczrwgjqfqievhjknoogsiqbmuwcidasfjpjssoshrnswbazjg", + "owuhtlkjgxsnbklpxfktmxigpfvwbqycbddqjusjomimwmyqfruqvzdq", + "lwlkywrvmomkyhyvojurtkfyrpvgcpxhffkrevmqyedjtcmybajtmbncqjikonovbcyafvhmdvxhvttoawlficglvwb", + "hlroiriirtisyzciiaediaepfwvshhcjwyltftuknweysykhic", + "ehuspkljoecayojddibelhdjsjipgjrppzcmtfcoudxzxmsquyvnvbkeerujcxfbyxzbkxylkxfdno", + "ymjdvrksfanusgclidfprhsjwsptacxddopzgsofvksa", + "sniytmstwwqdgnokkgijatganspteruxbzfnrivyebwuvuisfyfxgwhnhsgppstnsxqwqmkfkkiqx", + "pfuvfntdztosfvewxeyqumniikbxjghbjgkburzplmnovxpsmwrgltes", + "ntnlvexlypcyuxtqczwwiqhx", + "eovprrcgqingbtrpkodmti", + "iluwddpziaoxvdlwxhamawwpihdwnjgubvtpxupeywqrwlaoabfcvcplamkpjnzbulcv", + "qudvzasjicxsbgk", + "iyedjqoutcesbvraddyfeiuxalzmdcpphuwxsrbkjssrd", + "noerghjhhdwklpwnuqmvdjjosvlqzulyzevjslmvzuowiimgodnaswlidtmhsokkbvdzlssujofuhnexuulzaemvdl", + "fspijjektloqv", + "xqyhpapwpatwzlwbwvspnaibjnflwi", + "qcuxuncno", + "sankiffequzletebxrtsrqfntaszbynfeowwxwhghtktnmrvvfslkcayfitbpafpac", + "vvevvdpfkvafgaabdkdqdrdbhtqbcoaszzdedndpbkfkmloiqwu", + "dqxzjtsugaynqloxifdeimscewrrvtgmbdaunulbqukrqnpivybqigkthermyjpxvcdgvhqfdcewjyisyhvqzgwuefsfuecsv", + "dscnaptszjdqpaseeifjeczbztjtsvndlikwlmbblehrmmpyrbtbguneqjrtfjyyfyzxtwpcqf", + "kkhiwlpyudkujbbpfzjeklaofpnzdvtycdxsotnbbzkzdkkuytrfhrzorse", + "akwpzvnwobjfiozesjkvryyyxptspnxzneumwrnhjtfpnm", + "czowrlnhiksurbaauuloamwkqyrhlmfnokjdwpvldrrvfrutmgcohnaleessmmindeeonrjmzdzkhkpozlvaz", + "qwulczmvslinydd", + "pefb", + "hayknhkrbfrxvedzpvqahqkzmasabbmmvulgqdyqmutku", + "lsxfwhfmdycwkzgoiorhnudcnnolkyksrzxfjbnxrhtaxgbdhqtobeqpfxpoipgminrhmmezqzzpladpysepxfj", + "cyopjrppyirrlwkjtlbcrqqvdvdcazzvqnkdsodlryzhay", + "wpncerzfkddxzzmlqpqriedjyjvnhqvszqlbujtfqsinaqdfslfttghvhksylx", + "tjcbfaonbdpvmppkueqjpwteqzlyoybgicslatysdhfkk", + "kpv", + "lu", + "gowlajujptqhgvpzjrytadckwcvukikiobxnaowjavgsxcqulbpognhussonikhsdbpcnjcfiejbpovjqcyjwx" + ], + "\"vbwwxkh\"" + ], + "output": 0 + }, + { + "input": [ + [ + "ljtsjvfmokfnmhxdewnrru", + "tshwxqobstwbxxnztbcxavs", + "zczydxwacjeysjfjxmakqghipxsexdfbzbiovqrdzthpfisxegdaqyyohficmvnjxwhwqudprvlihoosc", + "mzrgonslmvaiduewegwlkdshknomwaxtomdkqrsfbvunuwmwccatgxifbibgxogcppgqoqseeahuroxjyzjpumnh", + "juzhhdfmaydmzrafgfodvohjichycxahivemsbqdnwmcafykwqwymtdngemvzwkbjsfmfbsiltjoqmsb", + "sqatcfbzwrgivorrncfizoykndoteynbacedyenqrcnsagiuwssenqaawrypqhltrariiahdmdggffwttxribxzrgvnhtazu", + "izjpkbuvbkrplvfmjlpdkfgnbgmsmlvonyvunnarrigafefkspwzhuxepkwuujiatkjokkeunegygzjixgtcztvwwbhfff", + "xjctrf", + "twayzuruahawrlmzdazdvvhonodqvrtzlowtiidrqsrmmbgjjvqssymfnpabzbelewqkiscopmynlkzsvn", + "wksdxkhwgyaelagewkpigzkzhqcsfpgvnqhgvbwgissikzoicfaasjfsblsdfzedzbxgferviwpwljompsgtjtm", + "ciypblkniivjvsdtfizudjwxqdmxlbkhazjjgiwbpmysksmttlyybh", + "olqbxhwwozvlodtxynamudbfwlbjfjh", + "igahchmzrqbqehglghofcuqhglinkkovmkhxwbjnampfecucrythkesrigbxjykqvskktztwtykzhtjifojhrbdfoqyltrwalgmj", + "zhzgqbd", + "sbapladgjlvoiujeucnbemfvsikqctyiqkefihszuobjcvbnhbnqalokwfejcgwlaygessbxnkuktmrgdxcsnfqmtqk", + "devwxnbotxjezioqaktlyensiociplftxnzgzbgdoaddtoqtpznrsobqweluseikeajfwmxvvuefqrlllrvcijxkbbfshnm", + "dri", + "tsvcufbkguotpdympjyromqvtccckljmvlbvfwlxohqtiztqqmzsamkemovzknakaofrgiaodojckknkjkxbmcoeojavehjyy", + "teimjllgacovcuelutcpmuankwevtuevhbibefurhmjfzyhwjjcksekjyqpsuhnjcwuosiiit", + "vnbyuiqbdapmiivaqgmhvbblxwrqoujtcztiiutqlxzpvlzahrkszov", + "otvinbevvbpnoxxx", + "ucnblwahtgeyztczafvrd", + "hhvqfzwtagfuaykadvcsfmxdbhopkpqffbjrqwgfjcayfl", + "frz", + "gczeardxhgdkoj", + "ybunplmfeheusbfcszgtjpn", + "lvbunqvaevmnrtwsjyixwtzrzdgjwmnjxx", + "tswpvzprzxpiyuxvcdoamhhakptwdqnjgjiuyipacitgkgawhaakkxurosfkdqvigvtolevbshb", + "pmokjzmjupspwwxktbmqxpikhvwzoengeeuvbxerbhgsvewlegamgcjeeeocssxcakpvfhcqxpstdihxdpitnipurmc", + "jzdvtpcuwitxihbwtreeggkqxkcstamlnznzrzglaicalv", + "ptdniudrhvrdwtur", + "lxmgiyqxrowdetmerbapeza", + "pfqffoukuxbjvoeldqljuckoapbsgcdarqzqpvhapnbloweglezfelmipxvxcujztbawmueefe", + "ufiiaolggnscavdaywwcrfdckolanfkaxzinijeomehu", + "dspfqjbrxhanstxtlibsqsqtedxzkwlsutcjpsktjedyrrgaauuitlzxmdsjoifkwamkoryowvantojxtvyo", + "bumswezyfzcowzjoxusxnwekbrferraktnzeevxhmxhlwddpdbaawjmiwvccunduxjdmtjfibu", + "lnemqgeebyndrgbjnpxnkxscxailee", + "npmzsfuezep", + "adoopgzzpol", + "ervlgqzjglwakvqmfcnnljfdplmkdltlnmwbqihitudbbrjazfwqfhjikzjgzzevulwgavzpsqssyqxsbrdzdajjkgi", + "emzxaldiyesbezfzugrvqqtejqblolqpvboikrzia", + "iblasxpcsqnlwvgbevmbmskrfhqpqt", + "djfswoicffpuuwxejflyclbvfpbhsylairrhclqdoodrkaxdwdryisotouvqhgvuowccalmmyomxmobhyryw", + "xlbqmrxihohmtjuuklqvcrsryikngioqwciduzuxgw", + "yttgersewzdhgeplfwtvwnncmgzgz", + "fvjkybtqrzdejqkwhpgeblaqtuxiapt" + ], + "\"roqrhgyimftaccrfcw\"" + ], + "output": 0 + }, + { + "input": [ + [ + "xxmwbktbugvaikeuaogopiywmfeoaoqvhwpwuzmqsecxcbpzkndchnnpxzds", + "woqe", + "kzjpylutqeperjdcefzafufqdtqudhakkdbhcfandplrfgjbwfofzwhlvsdxy", + "kscwcyykjzcxvbefkimpsxzmxfbyfvkfkmvwtqqmtgwssurerslgmaepgmsnbiqvlc", + "hgudgydgymklyziacezzqneppdbvttto", + "bfxgyegidjomjxkwvcgsyzomgktfe", + "btlhmqlqqikpxqhlmxekbhnfkxclzecagsywsnjjo", + "fzqtlwbzludtsnhzzdtqaruvvsqhjxcmkpzspvrtlumcavtpyqrfppianqlamgmoaby", + "ddigouvlksthkcdaxriwcrjlcwnlkwreifiwvfmrhgnqzmiatqujnoqqarjpwdvpemmpxwpwulfhphosfnacvlhidcdxmelzysc", + "ynqqlgxqpiyhyjesxvqgeybzrbrdvrzlogrpjuiovibelplzgqgkrhrsnvitvgiilnlrymizzduofzn", + "qmalhnzxkw", + "tpwtocuckibxgyanuvahoexpjxlpkoochmgummszrlfvblniubkstpyy", + "xmcocpsgazubmrrojjjdkxtgnhlwjkbeymhqevojbpmevltynlhcxkxdievufokqydxfyxxx", + "tvrmwwqbrlzbwihtlvieubhubrh", + "cikbpfkkuatykddpbstuvvilyriydsqvmznaflmzfbhmluuazlbuseuibaqfpcjlo", + "nyxbkqebsingbqvrtqpytvjrewevvvbjohhoi", + "yxfucgbdkhjhagnocrlvydpuiwrrxkbuaopxpnmcbkdjyco", + "uirhvraybhmffjvywqcpjmuxjhwrsdployvjianpfxtocfjmtsbhrirocaspyjtxxdiiknqfnduiindsulzonxtndimtyqtz", + "qfypzofxpqbnmferptluwrcgfhuhlulrppicpijrxdetrzlouduutnsmzqtuq", + "wk", + "lekucyac", + "mxtlpqqaujnypgklewvldbjk", + "jkytzomcbflmrhpuippkihlsgwomfmaztrutfhbpeylnfslnmftbzrps", + "jhvevsuzxyqukcndmhgvltfwykztpnjoabojmqxgjidhsqbojipsggadldtyvwxnhud", + "vttxpkmrysyomzsrqftaluuljtehmwvtuveyiqnkjbmuzcqjhmhkqvktoumjnxgznhkgrkdug", + "fpldvshojeuukpeigbkkwstjnitxcaabfinaazv", + "vtzozglqmqrtkvjveoailfnbgccuhdeezccqfcvbtevaeiedoqyimvafjkdpmtwupcivqegkxmkezbovgsm", + "reuewaxvekmolarumplvgavgeqgwswjcggonjnozduikspxyzhpzaevqujivmpaospwzstkwrqslfqszukzvxav", + "hdrvcazbrnbjjlfqgypcukgfjbgdjayuw", + "whclhtthrxbwnmttmxvmkladecfwwcxgistuyhvyfbr", + "tuerdmfmzfllaluprhrccotwuvecnlryfsyhmunsmyegrmxrutklknfcgyjjbwojo", + "xhyezmtqwalfauesbjjaliohthbfdjzefpfnjuvrpyhuzlhhx", + "vezokypfkmfployzycqua", + "nq", + "fkjplcgxphfmrjumydybkacfhsmrdvufsnekuzotvizennqioslioknxxpaohgyzlvwmvtcrmoqfxoydbkzm", + "fqicorjznifggcsaxugeyhbcbsxqaulojxmegxsohwqjxwktvxwb", + "rfwqbolsdxlomdwpjfvsfmlklesneiqxkupizoguyzdxgddmgaapnlzbzioyjzmz", + "pemmbqfbgxioeuudtlumbemmevdmmgbzmclfuqusijnmtzqxkaujupdnufqqlfncyqxmyscmnceoadcdgrollwrbtoxtljvhbct", + "dxzfmqutnbitjfarfqyhtjokfaifjbehaetkmqwwrpckdvovnhxdwpherruhunkoziqrhnnrnledyijztkynhbxvc", + "vodgpkstsklypgemoopbdbavhedwvk", + "ntmfowlzgfehtiyeqomstdezprlscajvnymvvxwlk", + "jitcliafyzepzpwmgglxbwxzzngrbrqayfirjtzdmgurccwvnffyiufzfxajuzetyfgomnowueawgfyzotrhdfqwmpdputqrm", + "skqnbkeiduhnadxezo", + "ylgemdrpuwuoeobzrdwrxqwgiywavuhfajsmkegfkbzjbzetjdssjzumgmryikyettkuhewt", + "xpaxiwdoluzeccayeewkdpzvqlqioniinngwrmlftkjzlpicfpdhfcqlpieugepfsaozisxal", + "ftamngiimowhqttkzyqyolgxzgazwatrmjquiwiqwwirshgxaubrd", + "kwijkdjybpvjrpewkjzghdxkdyngtfvxzlllanbikpbmoa", + "ffmgeyxxmnyoosnylzbkjotdmxqazyqzbupdjhjmbzohljvvalcwghmdbejicxcipcjbjeqyeasgacvveadmmqkqhfmqgctydjo", + "gevknzsrksglgmwrxwbtwmsqm", + "kfryudxxawnzuisggjgtzxxgjmkjrqjwdnxpgiufbkbefendgcxykguukvggtofhqwriookernydlrxwja", + "fctolseyotttrcerwheziaolswnimalkcrrpuyovbzobyqvybhrcdmiydgsvafhutvoulf", + "nkmayzbhqqqglfebtecxdjphfeqyvdfnzkeathwphjiosqylazvgkgsderwbx", + "ajcteuahwfthzluowwwhrfbxlxeyicutejgciafexbgugxboajhvopbetuvuoodlkemhvarxhimnuuidnxrzubygenncvrrx", + "ygnvmdqeqsxioifoimtmxnyvdhdheikeffvifcvorplfvzzxgintvtaxcaekpszyxaxpmtcsmmwfvjdby", + "drbpwbdpbvoyjqnwliktfcddjttwdmkvtsncdnkxrbgfbxfbvsqevpkqiflaplmnlnegthmhpfnfgdjxuhlpuk", + "ehnlomdcixdkzjvaabb", + "kunydpzrqscjzbrgjpghtquaifgjiegmsnuqgbnqpgkhmnfxwryqplssomemkzkbjnhvwhidnjasmzas", + "gcvwgaiobjatetybkmsfupfmncdmbhkvfrcmuondyn", + "uagqzbbqnqmkwvkwukuczrbvbaysgxdeuyphtujdtmcfzyhiyohfkylgfdgeaqtwtgbhotnadzambhwdqitbfnswbgskpyxeu", + "dgcxsotvyzrdnunqnxvadphesjtxybqjiinaxeugs", + "nyttzvlpfshcffchfupotxbetfsenxukwkmk", + "teudacodaacxijrnwnxggumjpptaowoizrofpugobvtoukveaoyufpsmvbpmokzfxghcaept", + "pawawkvzoqtaplnhffkvaspeaogfrjlmk", + "drztkjuhlcjvajejaukbbwvwagqzkdqmbnhiwwphyvrpecukeorbjxpegkydgbxihebsasgk", + "afmvaieayxypuadvkjzhufpeykwwggnpi", + "jsalfrpzm", + "yxegyyxlnkscccagbnk" + ], + "\"phfcjfk\"" + ], + "output": 0 + }, + { + "input": [ + [ + "mxkln", + "wdurbtyzyiioqforitufxsirdwdmynobswjvwenwhmipueujodfugjdrktuzrylkesjgrthegjyujezhqjmngupporjvipwmna", + "mnguiwfsqvrapiqlwlkqeipztcgyyvetslkfjavdpir", + "xbjnvtrakwalkommpfrphhanbqsyjuimpszncixmeyigqxihecborr", + "onsinjmgzcvnttoqyitxkedmebniqtoswhzuagatgwattzcsiqlnynzaomnxkfki", + "nfdymvovyhkfykukqnnvwpubpbbzzucdmrprbffixzvruzwgcyyhezp", + "tnkwfqwpezyifyfkgxzcmbudcveghaulyiuzcpprfyuplyhggnvmbdbnsyfmgua", + "qutxqdcxvtulnanlmoanmwnkgqsktryerskvojjvxvttoaozetzbnyxhgmjmysdyxfcgtgssx", + "xkddttwgphbtlplpqlqsjuznkohdltkjuetcvqnxqafnuicqnjnwgesapehcph", + "oqvsyikrxxluolcgcsvhzdvnmvxpozrvgydilsmmjluccnfszeksjirkucbnvgjlapd", + "pjlqjjmkzonkcglumwtgaeuuubsxdpxwj", + "snxolbmgtmbyhawjrxmtxjxtmqaesvwyeuwngcyvpjjxiadvqfzo", + "illlyujylsydobipocpeqxpvirqxifjnsszjsurbpoldcwyyhsdmagedmvlaohwlfxystyts", + "lpdzoimcdexuyosahhqdfzpqguvqgghprizjwhsjuefdj", + "nbwtgdviiekvnnzdlczrkdwfzjpovmuwiwnbcgoqzxkahppxohaytpjgkgbgezcuscfi", + "ubtssvcayyxbazvfzxfwrmtnlxpfzkmqrpaaxbmroiwgnyuslvypxykqsodmjgkdayzhwoqatmxkfjdoclbfwc", + "dxbtekyqomtptkkugmmuoxezkjhsvfivtolwrlemlwogzkfqlzzqgucxtvgzwidruwlkbsqildturacouhdkwrhgbwdzpvlsyj", + "zjjhxsijeobmcogutruyzetruuccocdiitvn", + "xnwjnfvfbubdptjzmnmxlxwchnegasqjpvqyxjgqkhkatuwyjzx", + "nvqkjzydtdxieqladhf", + "ojppunxwyvitqitlhuwpmujctbkeopxrratenvkho", + "ipkukmbffuuyuidfajhwacruxepjgbhdvkeuyvsutpbxmclywrecfsteattesujbphqhrqafnnavnw", + "ymoidvowckyynzomoblpxskmrzthfrlculhgugsbccaebxjjadcnt", + "clevzdcnxnjtgomaayjwtzcaynwomkeccykogvtzjdlbekvwkidqowjpbbyj", + "t", + "gpxeckodkkozeubbsqicsllffnbmviyxusvgrumgsycopebzvpvoumwrsghoxtafjrdubgojt", + "rgsbhtyzjhxcanuyfowbfloznaygfcmloahghffdvoqwkdsf", + "xowiafbklibwzpwfcxlxfksgmd", + "phjnxurhmftrrzcscojhtihbzwtgiqonxnvidjmqqgwdtolbpjhvgmnuourjrzzdjrkornpowmaubkmghdavappjfdgaqens", + "edfhtrbdpvcbrlthrmjzjxucmhfsrvoeywotyyzdiiozzdqrmmecyyrnacociuvnffoqxtnfmnhziwkvnhqusu", + "ssizmappvvpiasuzolsccyqgsqlrgzuzqzcljzrmvvbdytlwqscgxehqigsxzmxxyl", + "exdrzomoncynbitvdsmtpleucbzngeqchqzimakhuqxy", + "evopbyngsigahnzkkioerhrfkzrfryg", + "lmvjzkwhpmcgoskgpvnhkpsaiqssxelopvdqffgzswglyngssqflkgogetsiggmhadoexsqfs", + "jkkliiqiyeqoshwotosamxmi", + "alhlecsshkxbedwvcojhvlxrmhscxxjapwmiimwcrhrfrjbtdxozuqsrqiecmpzxhehmgaivzxroj", + "tctiapqwsqzsewekeowxplxbfswpkakjzdonvjuseoygekhn", + "prtfvbbnymwguzwhpjrrlpbgvstzrwc", + "bpqvzvhvizkjaizobild", + "hqrwgkckolibmjusrejbofvqcpnzlqflydbtcrwfqimfcfuxdfvamicly", + "qqfpaeybeipmgjsolsjsjpzpqyvwl", + "xnhmoniicqzdohtlbsdqvlufjooakvioyltpnxlzjwjhkgyxeselmjftuqoiwayoeiyxpnavhlr", + "pbpapgmhfctakmohwdjwqgpdwuzkzjtudfrhrmekyffypbgvovrocggtyratsqqbashroisqryadgusxuhxxrewciza", + "cavfjwbhdbuhqjxnwctsiftvymfxwedipessypaeifbwekbghwbkmwscuynhlggpmldqzkdecsxzmw" + ], + "\"e\"" + ], + "output": 3 + }, + { + "input": [ + [ + "qdbolpxebyubdhzzqjoprdlyjnholqepduhkgcfqxgfwrmimztqlsbcslfjrhtwangbpzbbdmc", + "dtdearpufjeegycauduylshdjiebwhifsyykgqzmlqotnysvcxiorhxmqpufrjopsvvbhozeirye", + "cresbbzpxkerdpgpxaihdfmruoopellhatvnshcibexhoml", + "poomxkxhhwlrzadedr", + "mtqpgepavtrddkwlbsqqkcgwsvvjszuavxvkagmdacqhtmakvzn", + "xclmzgicyrrmavomezwmwosryokpyxtaaybhgidmplvhjvmjpnmnzkxbmpsjhqhjhiqcxtskvqmtuburmpgo", + "icazrcutugqjbmjujhycmecgenuk", + "heekxmokmulmcmzvwbrmybhdvlxacykxved", + "kynrpdthawxqaufgicsyiegksdohajnyfsmcueslqcperqtxcgpoeropklxmwzsz", + "mzhhdvqejl", + "konvfsuhyskitkkudnunwhmfcurbpvriafaifzwkifoaseimxwrchziuwvzoozxqefeewhnteeltftyyclalqi", + "nphhlntgsfvos", + "fofdbqxvatrqdhhzukqzwaxkyaxpdjgtcghenhfpjupkesyjcnifbwnawhyuwtyjvufuqwexanevhbwpmwftbby", + "wvnsarwjx", + "empopwloqaomckrfbnfapqbkrqbxgekmfywzviblvbakvtnpzwaaqlgdqrsxckwrighqangfmsbjcheaqtdauhvbfecftn", + "nszvgahgjeslfrrgcviqowishpcqzpfecyofqnjjehwdilcrvuhtfpiyrtkeopmvthitqqxgfwrhkf", + "rpojkucybjveuxqegulkabdqiagmoirainhbtyq", + "cweujbdmrchqqoiupgmtzjftpurvnygdrhccjydltjnux", + "sqrdgujrnyvadamymwdlsfqlzenteucnaxlmdpytommuwvpv", + "vzgzdxfujvalfhttpgrrzrcwdbjiijxtejhaao", + "svfjxocenlfsnywckuwcfnainhtjer", + "aumfcdesocalvlwpviamvtpjptshdwyqpbpuuzritsjggcucpmtq", + "vqeujeqjnvjmecgyxgg", + "iswnbeylfspcxvartcrbyvwsdidpyhafbfefpwewhtxkutjdjsfejsnbtzscegcipiwwywqfigxqrkofsh", + "fzblzuvykonuwybx", + "iedujpmnirugqochyqnzfnojlvjqjarmwynidbpzhaelfocrlmjtpbnacyuxyedoewgeubpxdlxnfavlztohuxi", + "jrprolseezacblatfzoyzsvixavtzlpugrbweevxvqitqhphqmxncndbgwpdtf", + "dsueadpbkdcbwuzytdadmewhpvlehpl", + "ovgcpgpnyflgxcqaxtgcatmihupsemkerkfideszinusjjevq", + "otndcnlcqvmbngkzsuwvsualuxtgaljefbsaacnkvnxhvcxqzrlpbdaujnkaswrfvolvmfmrxslkxgevqsytooijmxlxvtj", + "ntttbisxhumjhfjvzrrcsxnybxpktscnfnekkgbfgejsdqydujijgbudunwebyukxjreymeshifurlo", + "zbktqobjxzsxbpxbnlhgurvuieijdrfwbzymptypovjywcxbbcicgrgnowsxdzqgbaprbhopmqtgsyy", + "rrzlcdlqziilqiqndcvxfyqcatpqzerzxxscaizeyevzsmdhdugwvvncaitclilbxiftaoexctmtxugwnuhvfwpqgtdwvjjtjoe", + "tejkrpnfnrnxjxujusjuvawoyhmcqqsrcnjgfvfexgjpbaxenhsrtawurxiynhguagwz", + "dajsqeiwwkdwmfwneunwsqdpafczwrkrbsky", + "xybesydjzoiokkyauk", + "fubewtwyirfobyfvmiubecspjoizknkhludeunvzsrzskeauaoccudualilff", + "nuxrcmhcudhraztaouewqfsvnpbngqizcregtuaslyzqlpbynxnbirqktvhosuqunmutxjavdgqannhtzwmypwwxqo", + "yayxdalyqdfmvpritzpgjaydznzcwxdsuhyserunljycgwacnmcvefohzuxefvijutjgakcd", + "bwzzsodagbesxsaiyvlflhghbxpfmvqfozqnclitxaajzsewnygatdjgeascaqjfwjaoqjfydcofisgvvzkovauzcgwsecm", + "fzptuguxfkifslcfpxnyukkkcdivgjvzegupfpaomivsvysgjbrzekzzluvlxzzugxxookia", + "ufgzunifzopphxwflwhkdowlewvtuiekmgreojgsmkljqnhvdzf", + "trlxgyhnralalvwkpktnfqkskwjxwjdvnyjkotmgs", + "pxuizvomcvv", + "ynvakiiamjxxipbvxlciyffcrysojhasbpeajowxjhgkelevqycnysanzuthuplxncvpdwh", + "vplqgfbqdrkqeqbqgsqoscqgpukoqypvayzxxp", + "dkxkfbclhwiuxavdayqyrfnxjzqjgfalfrpclhnkffacbbwiyvbyzqetfdhouzqhqgvtgdhnxbznaj", + "peodqhucjqexxrmdofjznyncbllspqdnnqimxesufnmgmt", + "vfvdhgpxamektgwrplzhiwxckcndfjdrnbxzejxkjtamduuilblwqtrlorgxoesybrjkaxhkmxxxfebldiw", + "diksjsgodtlwfoeddujavacrgwpmjzynbpgigkavkoqzdbiarvvnbsadzmabnhsgeegposfpqmttxlbirwsxseorhczudijwlq", + "eist", + "eir", + "camyzxcvveowikozeledwunlfiyzbkenfkirlblvcsrhzyiehclssyrydywqoghe", + "hkwfblfutrnskxyaxclqmwmdatafvalrsnamigxvwnzqhpjvglvxrllffvgpxqwcgalqgqla", + "zjufutwatnnstqqpmhqvnpyczhtiiujtiqbwenlfytaekusiuvvqr", + "jqyttiqsktpoaeypdzeovutcmefvirofxblopbqptutswkuxaqpvjvrluuhfgpdmque", + "dawrxj", + "gzjgohharlvnlaekxrqxnbueytabxmrvluodftjwalmlamrmrunapilavmkgolsqu", + "ivnhbenvbgertlfwyzevervmfkaxifksjbqkfhomeaiftgpopuwbhzeavdilfaqhxsptiiknarvcaxdbpdmffipxtuxdvi", + "xuxkvu", + "wkmwigmddlivnezgyboryefsehrebyyftnurzhiytijyuesnmnbsvybmlcfmvhcksmzdjmoychry", + "ncgdvkxobosmxutnn", + "rrxjsipw", + "qjtlsytztimpluzxwahjzmculiipxkidzeyvbuvkajbhvlbmcrjjzvti", + "efvlccvetmxcc", + "kjojpnbxz", + "bvdmzesnudkfkocjygecfvcgecpdttiwzmxnmsbfrfwrvuzndquxhcjg", + "oucneodyjksrxerbmdobjfgxqmlwzsaxznurkmckiughwjgats", + "jbej", + "cywljpjsixuavixuxyhoglaocdablnaauajknwghlyzgpwifnkqssfzrgtqvbjpdqmrefmhzudenp", + "jpkxhinuubuqlkorbczwcclpbbziukziwnsuxmgyjxxoabmtlsvmxysgumgucedntzfxhteyzbofuqtllehttk", + "rxdwwqlmuvhxnllhbfuisrpppfffyhbmwlubqbzlqysmuk", + "b", + "gyfocqdizpblvfvsddgozylskuswmncaelcoyiqsaqixtozdvgwvuhbwuzsdkpysmfaaxzifgckstbozwx", + "fxqjladbnqarlnxnpkjmkdbyrllwfikaadycevfneyttnzmtoxqhnxafmxsxxqhksfcioxxrhxrvq", + "dylcikjyeiulhzfhhvlwkifwzvbchaowufgymmwhjycofh", + "fconurbgvbrfuqeyyetmbhxvwv", + "pimmqfdqfgkuuweuxsqwfhgabofvqekfvvqlmjtigshjixwudiswzjsfibpnkvqlmffskqitzqxiullwhwyshtp", + "nnlrhglwhkgthrcyuhqzzhfnehofunrkgjypjkaayptpkuxq", + "pzbrddcgrxakgzbiuvnyowmfpadhhbyghvhkkfimxymxbwkmriiqaugjotjesigftltqhirilw", + "cfuwftlugnkacugtmcmdpgpoglvaqprqasqejghlifz", + "unmjsnshitf", + "etzkkatcojxektbytebqxhrhcsljmrxfnffwvbgwufygwgynmkkvpixkjlyhkgohtwakhtdtdjoijcghtvsnsdqlqtkvvbd", + "dlytijthl", + "utfjuiqopvxwdpafqjkqdoxldxfvssvhqgpipmcrbsrupcwpqznrhjdqbi", + "juvkwpvumcwdkewergzcahverjqqnaxiqaftqjequdhqaibgsfzvkklrgkiegqjb", + "qzaxlfmsvadopjycfuftohjsfhimzcxglwwubqvrljohxhsmmerntzgmbpibolxknbyzatwixrkkemchirnbzfnwemnbuwaqqy", + "kfgjfgkdutsupscvzzohytzfdnwwnejgvlaxqdkda" + ], + "\"rmn\"" + ], + "output": 0 + }, + { + "input": [ + [ + "jyfqgskwdphrogtdtotgdegdulezrvqhdihusldloryqqjxtlst", + "bffnqjgpjxbwspjlekbvdabmncsgmypjudjgxf", + "gwfvpkcazzwynxcnkdywjdtpwogebejtetuknh", + "ebfctazlpvzfbsdzpoaeghvgubvnwfzznbzkuaalqjr", + "q", + "xvnmqxqajprxgflgnauindmzwefijhpuydztvgycmveqvnhpudcmsnezwxthiql", + "lvjclxyxqltdkjvscfugoitjbdoeurlxakfuxmuzzvyzjwgqtyr", + "xwncxviyqvjymqjucfnmcdnkauqnexuxoheudtwirjyizaxegwxrnmqcaknosseudtnasjtznmffxfihbnww", + "nzgcekrlyxvrfjxgishxjcmteclnqkjjz", + "pedclbczcfttdvvxkgqwypjaxgx", + "cjrezfsaskfrkgsvylqyusrxdnszelwxtfzdosabrctavzjccebunfyrjdglqcpbbqtwwm", + "vbhgyzgmtmeifzfqigytatlkraimnvokizdjddqziezbjjikxqdijplxmamobckawlzwcghvdbsrjlfmwny", + "xvhmprvgdlqxfxpuwpzfanuhyasetxfhnrbaeugbrssinivieormxqcnyutjjnpsudmvaujqn", + "jduqkuolerqoma", + "wieywwvdflpgdvseaqmudaqwxerkdmcdglinwszhnatbytktruzrafmzkxtvdesmredtouomksumsrgaouqtzhkslrpqe", + "yozrmfhgqiutqpsxutiimjmskvuhzsphkosjjdttoaziznhfozrdvdtbeawbgnghgxmwnfsvuaggd", + "spucznafxpnkhneptfsapezvzqzbvfwcopdxpffvwflbdt", + "nyxlbzjqsgenbzndsvhclranibbiexnxkgoezwolatnmptqjmvtulytexdw", + "xjw", + "auatusqsitbfkexcqjqxlhamtzoruqphjdede", + "dpvwtcvziuqxcunpswjdmnvdpivgyxaicgclwwnrrezlg", + "wwoukb", + "fehqmczotunlfnoxwtfwpmctnhzkfnuq", + "yatcleoxmhtztyktdtlotuwlqaidfilgymamuypwikqbtcvkuchdmqhbrxiitgumjshusvpuefreodhkuf", + "epkyizvnbywympiurwbbfhtobzqwwstiwcfvgmkujcyguuntevwkea", + "hqbqlunungjquerwujkyjboleuswuiiiroskzms", + "rebzwcxyxuvhqqyzhcxlbvrldflvaaoalnpmxij", + "iqm", + "svsdgoxukvpuveijeseiprynxqosjxygxikvnafyfiq", + "qtoomkyplsvmvalmvwomethtlukdzjjlevucjmgtabzeekhqafayojavkmprowjkssrxavpm", + "svvickuobbrkorspsppivro", + "cmkeaiwthqaqlysyxutmielzwcsksdwvyucqdsnj", + "tnmeqdzzkqeqqnhjwfdtgedqmxooiawuvzygjlhdoewtonhltpsxnbtqvorxwyprybdoqfffrlonqtgkpwpnofsgqwcf", + "cduzhf", + "rdwzjiqzkzvmicbucggaejqvbrkvhzcdjyzgcnkjpttpnrdjurjcjjb", + "qnrvcocxhkaydiqodqvijuwdxijkimzkrctbyzfnnxhpgsjxbmurutkxjconzipvaliriessu", + "qqfiqjumdxeq", + "rgsadpidezodqfwdpjqnpmrnhpnbge", + "imwcycldyvbudq", + "deifwtypguqlboqpclcuqfeipkowptiwjnutacuaslecmmyoooqugikdjpruycatcyzijornumkfkpdoxmiqnyepddvcvhc", + "tihtptonldvodfplmiahfkrxjqlrfjhehtlysxbdqiwcxogzzdlmlmyeebxavkrpqemswhpokubbjjihvdnnjquuwqlbngbl", + "dvtiyfivmdgmamxpqwlqskrhwkuntnorcvsbgxlbtjwquaxtopbhfbugjbxkttezqvwunqvuqkcmbqgr", + "jwfpkqswgauijatytvnystxnyrwuuozlabuukgvvokbrhbozpwgdzelywnoijfdykuc", + "tzpykighbhmqfmcidrmropihxvtgfjlvfkiuvsmkbqwrbxxffuwbrc", + "fabmxqceiukhgqshenvvahzhvdzxmtkvdgoozksptzvnaiifpcl", + "vhugctpwmkohxyaqendzytpuzlhshrapmybbjtsfcmtingflcdyvaltlzpjrfg", + "ciklrzgqxuozskcpgnvnbdxjonjizcpzouaigpsuzybfoifihcosyonoeyfalmuqjhgnoahjxrhmyvxilphmtxa", + "bgnbulousaxjltyfescyxnpzyoqwrxyfhaazhgxksghwajwdgozcdanmtatnvlkfdl", + "tfqvkcpstwffhjdfogllerddrxgapdwwuumlgyooywebvhxiiyjydywurefopcfzkhnuxpzmdwbxgjiscdmyupfpohpqlxgpg", + "tepruozxyheklhlkdszvnknouczbmtimxzdiolmpjhczthfwsmbbfgdtmcgqnegyfcmhdnkd", + "hzhidpmuzxldgkfuzsekwvvtihrvqehjyvlzezeuyemlzkqnruwnraomuysaqysj", + "ilzqrukrxvkjokrdsmr", + "vvovfcyekgbecefwfzjscemrzmgrnlwvqnjaiyrlbdvp", + "sxxkirmkbwshvghdurogkmtqkzvwyucmwygvzwhnxafwzwetdkxorqkxgdbxpehfuhgtypaka", + "ibctejmzapmfukym", + "dbodjmtnlfsfuqgellevxcxljbkvgzhkjpzzrxewhonpavhpkoiujsm", + "joeqbknsqssyearaopipppzzbdzrbuytrzcsbwjvnymfcglqrtbsrgtgxgcpduhjhzkitczqairtqrlmvmxojmgjmyqyhonyi", + "rrpfmavoyeiqjktjssbolnxhhsvdznnficnwjgvtikauxgymfrtcwkzlpuxanihnfslshryuchrujtjwwvuqddao", + "ifgokyxytjmybzfyavfyoh", + "vsypkpkzovlkathobmnxoilvvmqkbauigjhnrfhqjltdkbd", + "frjsuiwqdoy", + "ocbuwegbgjdhdlwrxxncmlnfcgpuratmwhrvqvugcidjiyvxwhktbjmrlodoofwjlnhdanfnxwinyvxp", + "lexzmpdiuqkuzqopvfq", + "qofhjulfjhztjrkhse", + "czlrqoqcjiiflsnftorlyozfcmmxfjzyvbjvwkboqyqcybntbmdxveklktrouognnwkpwt", + "odlnxgnpdibjzsjhwpewqsqoytntlfapottjelltclfnvduywpccqzognyfjeleqrtwetacxexwcwongmmlerxuutmc", + "nsezqfgcdxfamzhogvinrihfkiiqzreojkldbwtnfrzyfzhiwkqkvhbookgnrivwekclbwzvjsaopqoxlgt", + "ycbjrwxepvyqkuacsnlbqxjrqcexjbcvuwvbkfjrlebjkqspytvfyygnmdxxefqldmizvstxsbyshoajjxz", + "ypcimafrdbrrsnrdkligwmgekiirfqhalllhwwlavctqbgqovh", + "slykzmnjwbpiidqbwurkrokmttrkdnsejjvhrjr", + "uwjqyuiccpaecbfwiszgxnbjuyytpdmgyxhdfrchadhhzaramhykmtax", + "tgflylkwmohfhxeycveyrnzppcorayaexeaxffjwuefqebgvpe", + "afmtcfktphzkvbooyxvdbqtdaqgyalhbyt", + "sfbagvagasmlvjvrqnrnyvpxmzwkblbgjnlovdyitnhdoyqfdhhnctfxyvvsedjgetsiltxacl", + "xxxwkntgfmjqqznjppupvjmcauzyd", + "rbyjsphwrngduwupubcuzxguvarjgmvnobfoektqjlahhgefr", + "hfgrhimsuopsiionftygezedeotuwhofzgbetssegupyamjt", + "saktkwrpsderyhghycsffktddgdxcyveewcacxhszrzskckxtelwbuuvzz", + "weeudpbabzr", + "qmyplppukemajyrrhnjkxjctcajcknawjjqndwginagq", + "qseutctfgngdwocgfscsejkmtjyyvdwasdqksykswslgmmnuovuzrqaupmsokxmmxodpmbevnxxywxrcrpfyumnvlemuhdg", + "rtbbjhmaymnoyzzstw", + "dtivunnvcrjuixlrjsposhaaeozjumlashazcnuqdahjnwxkndkjr", + "tjtvtrauxypjpahjgxrgunncckendizgrdvhwszrlwdljedfnvzninllmigygordaxwfktgzzwmunqmbirahnkjwlxkevfi", + "dpqblepcilajtcbcnklkwsjrmjbikbxynzfddyerhqhhbpgcqilpqqbhtnbjehshskamcayd", + "ngjmaahswzfsdvyqufwwyjojpfpgrngjjgzqgsvdqxejybhlhqkwloxzgadxvwktxcqumwwysen", + "oxzirhbooobgjerezoqahmhkfodlqkuksztxtmewbowhrsncbaftby", + "mwuavdtpgfzevqzylvirtzbckneqqmzwltsxszfgpefvqboswpgllsjjugcjlvanvlnybliaqnkyg", + "jdtetxdcbatrntrgcqkwyswlwiemqgfayirhrlvcxctqdkxefwobhpjihjzhckzmlnniidbqzugnirsgyyhegkqbudki", + "pramezblnufqromuwmjkjpaamhpuiuhmobmsyrtjgzdvpguuanq", + "grzluzpiejzdmxubtjxmhdnhsjvcrkkmmgegrdfsfdafvdxjafauvfnavocohabrzlawnzozursnctpijwdcwe", + "dpi", + "lohfbsyekyaehawcnjqmhhaaovhdsukcfphlcqosvxivsqzbgqlwglnkiwmr", + "btpqkxplrfviputstrbwaqhdhiawcc", + "qyd", + "pfopcaxxrggwnpqyngmnhjgsbuzrudlkzhlqefolqunxvstppoeb", + "ogpzsxhdlsgjqixcntuixknedrwfvoinfrhtsbnxnn", + "jsudmyxcdyljabuznqmzacpwcoqqiwxi", + "zcjdftc" + ], + "\"qcbjjnmicrdid\"" + ], + "output": 0 + }, + { + "input": [ + [ + "ubnwtszuznclbwkbwvqmjrghphulsgntmvzzzrijqtebwell", + "zcdpxbgkdryywyjzuwvnvijgxcsphoyzpsoxdicngyyrmjhg", + "vasuxyngdlkjnbtsgzxywdchmkshzmlfpsuqiypihwgacjanlbvlic", + "nuhpobjqeoshineuiuclqlmjzmaedtzntmsjwssmoqxkqudrrrlivhefvwaehounjlwjusddrhrvtopkzjw", + "oldqbyvjvhmyxnstgggskesiybydixeiwbtlkgfvfkbhrcpqzclcfz", + "sjjvilstddxcppj", + "hvgvyglxligmukspzajjwahgayfsrkhknubjhtlhecshvmownlhtrphxhivwnlbusnspwdfuzjtr", + "cggaqzddhyyzv", + "clmfbkikwdqekumczrwqczywhzlseuhyqqoevlknxmudlisqqjnxasvjfq", + "rzbzklxomzuqmfbatpzygh", + "fywfcodufmjslzahtfcprkdaewokefwircbtxggmzptexoxncmikstkbvjf", + "jcezhbgcfjqlolqkbcalaahnxckhqinnquppywgndvwtyfgsmnnjgywzpmhvgzlsyljhvutynfionndeqhqevskabrkyb", + "wnoiynnlwswkinbitjucymwfihybojhdjqobueqyqdlwgz", + "utdsgtmduhcunklhdtqrsbxubknwbuuokivvdmgwbxtikyysrauhbxtysmsvgzvem", + "shulvhvzjvgpfjbefzmbbwrxjgpwvjzylfjjwbqfxsoqyugemhqmoegacpokmrwfaphitxxthfqvuaabsevs", + "rfdedcnzendrewqtggwcbtkleafphyuurxbpdjbrimrpyor", + "hodtjsvywwuvrlajrtmfboegrgymhpcaszjjadqjzcdenkgmuxumlhzdbjakejoarstikruahildwasjbmszntboklzoxkq", + "oziijpnyhjbanubiorqypjbebaasockpmjeiusahdjnljfhlymqywoyneotbsobseqekmvpmvopymklagulgya", + "juaxmfhstxzmzvcnodzsyaloatquzniiqwfifih", + "mpppytaeyoqsrudr", + "nnujbibkmfwbpretpvduoblssjsahzasnkhfadskbzyphwnbuqlytznvrqyyzfntaypfagiemhghmasiessvdoghsdvrhlxzlk", + "zhbeqaszmunuaogcfggpbto", + "rjbozrkmwkqwznyxsujhhhrmvnphqlanhubpsdbimkiwkorzatckxtaebtrktlvvkptqvsw", + "ablhcyhwjahdbqemcjgaerwotxjbkfkzfpfapsbxc", + "kpykxsixatzuevuhfumlewjughjcwttffweljktrmurbwhshdoecmihmrinuyuqfeywmxlfegwlsslnvvyfyv", + "dptsukx", + "jwfvnygwrzsnzhwmsdhyxekucrmgqvxyfglabtsmpyfnsnrhzvvsmdn", + "ishbgsdtimdmqcjcykjtvhujfrkakq", + "mzupxgbwwzjkjwhpwukcksotnrynuokuckbbsovecxyir", + "djnugtsalopjbiydzhxydyddobglmauwktlnxworvivujljebmohmdbylwztbqhditxjptgkumzexppnurwlt", + "yxzjfkadpbwhbtwroaufpxihxoyhttywppeacrryvno", + "hguguinpbkhmknottpsaexrkbpmiqydxrknpqlevkvfgptxmgvdzelyekoawgwdfar", + "mkiebjkuusbbjpr", + "qghyviyhgpnbnodyzluxizjvwtgkcizpvludpfgjzhnhhtarnublqbwffostkbe", + "iwkuzxblxegpivqacgtoswebimdoqm", + "elnlsoexjfopzvhlwrzjbbqxakilipxazxmyuzekkrkcnfvquanyfgwtf" + ], + "osymtnhecqtxptrntqalevqshitebb" + ], + "output": 0 + }, + { + "input": [ + [ + "ondtjuipetmpfannrboejnotpbzdofygvocfijswetlgewetjwx", + "whrdxhhwbvvbnckmuvfhzwhevvpggqqnqfyxjdlljfasuypknfuryzgnmidlnoewmtijmelapxmaxqywqllruvubvcyny", + "hmozj", + "jjvsbdsimwrrydrhavngffgvhdtfxuhdgegtkkiovhncpumflmznibrdsqruovcrfezcopxqwliomgixsqmchrntohlhq", + "mrlxuymlozmxfmazchvzjabyhxnhdfvhohbydgcgovgxaadagjchvfnmooaiuoe", + "hareystxqwudfzsazzbtvpzyyvjlsrycxzhewqnudgmvfbheizmisktxgdpfk", + "dptnnaghvjlvkjksgsyfover", + "vwnhuwhlopixz", + "bhzjcdjnrfmmjfvmlxcpvyvgwygqbhmvpgdeirc", + "hjuerinnwt", + "slgsozchvisoxymplffvuxdqcluoabmitxytgixxhhoedbbqgvh", + "xcdltrmjwtjrigqhnajhvvidwcccdaemgaaejjtbpbckrdbmhofqqjjhuhhdrbpjsfjzkbnlgoaicmcjijgmriiucaa", + "qxitlhholjfbtscmilwl", + "pvwxodivjydffgcyghghnbempcdyadnakhxcwxkaxpqcfgbletuugjdxhhpva" + ], + "ikirwouzclvjgphnesvvtbcezrxpczwkcdmzhxkvgrkmjzwwdq" + ], + "output": 0 + }, + { + "input": [ + [ + "nxy", + "tsuxesjbfuntioremylymeikzecnqfnokgtbggoiwjfvrmnlgiawxavpxfllqtqfpiledpibtgjreoosdrd", + "mnhqjtdaseajtvvpridhtwdenxlhrlhbnvqtdxkyzogapqrqwzpmayoa", + "mgszoyffycbkbzpqzucbllabtshdmwflluxvdqrngslrfs", + "ybireohyzxflbnxlbfnsnopescnamhruqmnpvbjf", + "ogknvqjxjytqrfgdmvvwyanlkfvzpfkzr", + "lijokragqqmhhvfvigvjcppkehqzlhyvjokorbmkoyrjnulbfgdawxqcvxghfdbiuvuvvi", + "veablklthzbtpiphofbdbnralqxeivlkaribacoanrhk", + "irnovdlifhmlmnqcepojzwnqihoqwvvmrfacdljcoeuoywwlrxuyvgdhgsd", + "oofkasngbqqpirwlsxibi", + "rcdwstzcjgsbbxemyvjsyjudnngxdczmtozxdftflqsyvkuchezgrjsxumuegldzcoffnq", + "minhudynvqwelpvabfaawuoiaiimn", + "btniozvndvoeaurxtqlrpalgbilcgnmdlsqwkcifiqokakj", + "xyrzzwsfsyfccuwwuehybwalmqawukedxsgdcfurujpzigevzbuqelguollkqrvwhhhmbpouaeud", + "virukixgfszcrvypdwnjagviopjivqtvnyqrkxzpohfwapqroldghiygsrn", + "lzaipguij", + "qhsroskqzwbddmkqazyxninrqnunkorxvcfgtmjuocomsodspxxrhiqbazllhpmpwtwbisgifmpuzagkvufrzworbhvfqc", + "dctcl", + "yddwrsebivhtinvaznhipnc", + "xchiyffqnspyhtqrmncqmofmy", + "qeilvbsbmcyfbyvedoizyjzzsrlyoladikaeejfhvakzidvczltxrcxbpkyqaiuganwrghpsppfkcydgrceoywbmcuwbzkae", + "bxgzvityhtolj", + "tychxvuotelninarlkxvjdghekhgddofzcdgtpxmzwfquznyvpnuwyczcauwkuvihyadmvxfmkwmuvzdluznpnilwoftcdbayqrp" + ], + "j" + ], + "output": 0 + } + ], + "haskell_template": "prefixCount :: [String] -> String -> Int\nprefixCount words pref ", + "ocaml_template": "let prefixCount (words: string list) (pref: string) : int = ", + "scala_template": "def prefixCount(words: List[String],pref: String): Int = { \n \n}", + "java_template": "public static int prefixCount(List words, String pref) {\n\n}", + "python_template": "class Solution(object):\n def prefixCount(self, words, pref):\n \"\"\"\n :type words: List[str]\n :type pref: str\n :rtype: int\n \"\"\"\n " +} \ No newline at end of file diff --git a/counting_words_with_a_given_prefix/ocaml_tests/main.ml b/counting_words_with_a_given_prefix/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..45e6d628eaba460776b4aac2163069c4af7b334d --- /dev/null +++ b/counting_words_with_a_given_prefix/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal 2 (prefixCount ["pay";" at tention";"practice";" at tend"] "at") + +let test2 _ = assert_equal 0 (prefixCount ["leetcode";"win";"loops";"success"] "code") + + + (* Grouping test cases *) + let suite = "Test Suite for prefixCount" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/counting_words_with_a_given_prefix/scala_tests/MySuite.scala b/counting_words_with_a_given_prefix/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..4cb85860fe8d52e7e1dcaf4d74c70b5494f6a2de --- /dev/null +++ b/counting_words_with_a_given_prefix/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.prefixCount(List("pay"," at tention","practice"," at tend"),"at"), 2) + } + + test("test2") { + assertEquals(Main.prefixCount(List("leetcode","win","loops","success"),"code"), 0) + } + +} diff --git a/create_binary_tree_from_descriptions/.DS_Store b/create_binary_tree_from_descriptions/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..909076171f0e2b8e5eb5d7b69649a30be660e33a Binary files /dev/null and b/create_binary_tree_from_descriptions/.DS_Store differ diff --git a/create_binary_tree_from_descriptions/haskell_tests/Main.hs b/create_binary_tree_from_descriptions/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..3fbf9de5381e362b1c5da716f6f270e6c58365e0 --- /dev/null +++ b/create_binary_tree_from_descriptions/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (createBinaryTree [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]])," [50,20,80,15,17,19] (createBinaryTree [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]])) + +test2 :: Test +test2 = TestCase (assertEqual "for (createBinaryTree [[1,2,1],[2,3,0],[3,4,1]])," [1,2,null,null,3,4] (createBinaryTree [[1,2,1],[2,3,0],[3,4,1]])) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/create_binary_tree_from_descriptions/java_tests/Main.java b/create_binary_tree_from_descriptions/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..fa8178f412999fd18010b80d318002d0f247a71f --- /dev/null +++ b/create_binary_tree_from_descriptions/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(new ArrayList<>(Arrays.asList(50,20,80,15,17,19)), createBinaryTree(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(20,15,1)),new ArrayList<>(Arrays.asList(20,17,0)),new ArrayList<>(Arrays.asList(50,20,1)),new ArrayList<>(Arrays.asList(50,80,0)),new ArrayList<>(Arrays.asList(80,19,1)))))); +} +@Test +public void test2() { + assertEquals(new ArrayList<>(Arrays.asList(1,2,null,null,3,4)), createBinaryTree(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,2,1)),new ArrayList<>(Arrays.asList(2,3,0)),new ArrayList<>(Arrays.asList(3,4,1)))))); +} + +} diff --git a/create_binary_tree_from_descriptions/meta.json b/create_binary_tree_from_descriptions/meta.json new file mode 100644 index 0000000000000000000000000000000000000000..29361d6178e8fcfa33708686b2272c4a29bb81e3 --- /dev/null +++ b/create_binary_tree_from_descriptions/meta.json @@ -0,0 +1,26 @@ +{ + "id": 2306, + "name": "create_binary_tree_from_descriptions", + "difficulty": "Medium", + "link": "https://leetcode.com/problems/create-binary-tree-from-descriptions/", + "date": "1645920000000", + "task_description": "You are given a 2D integer array `descriptions` where `descriptions[i] = [parenti, childi, isLefti]` indicates that `parenti` is the **parent** of `childi` in a **binary** tree of **unique** values. Furthermore, If `isLefti == 1`, then `childi` is the left child of `parenti`. If `isLefti == 0`, then `childi` is the right child of `parenti`. Construct the binary tree described by `descriptions` and return _its **root**_. The test cases will be generated such that the binary tree is **valid**. **Example 1:** ``` **Input:** descriptions = [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]] **Output:** [50,20,80,15,17,19] **Explanation:** The root node is the node with value 50 since it has no parent. The resulting binary tree is shown in the diagram. ``` **Example 2:** ``` **Input:** descriptions = [[1,2,1],[2,3,0],[3,4,1]] **Output:** [1,2,null,null,3,4] **Explanation:** The root node is the node with value 1 since it has no parent. The resulting binary tree is shown in the diagram. ``` **Constraints:** `1 <= descriptions.length <= 104` `descriptions[i].length == 3` `1 <= parenti, childi <= 105` `0 <= isLefti <= 1` The binary tree described by `descriptions` is valid.", + "public_test_cases": [ + { + "label": "Example 1", + "input": "descriptions = [[20,15,1],[20,17,0],[50,20,1],[50,80,0],[80,19,1]]", + "output": "[50,20,80,15,17,19] " + }, + { + "label": "Example 2", + "input": "descriptions = [[1,2,1],[2,3,0],[3,4,1]]", + "output": "[1,2,null,null,3,4] " + } + ], + "private_test_cases": [], + "haskell_template": "__init__ :: [[Int]] -> Unknown\n__init__ descriptions ", + "ocaml_template": "let __init__ (descriptions: int list list) : unknown = ", + "scala_template": "def __init__(descriptions: List[List[Int]]): unknown = { \n \n}", + "java_template": "public static Object __init__(List> descriptions) {\n\n}", + "python_template": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, val=0, left=None, right=None):\n# self.val = val\n# self.left = left\n# self.right = right\nclass Solution(object):\n def createBinaryTree(self, descriptions):\n \"\"\"\n :type descriptions: List[List[int]]\n :rtype: Optional[TreeNode]\n \"\"\"\n " +} \ No newline at end of file diff --git a/create_binary_tree_from_descriptions/ocaml_tests/main.ml b/create_binary_tree_from_descriptions/ocaml_tests/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..861f94eecc257b000507a998023b41aa2383b904 --- /dev/null +++ b/create_binary_tree_from_descriptions/ocaml_tests/main.ml @@ -0,0 +1,26 @@ + +module Main = struct + open OUnit2 + + (* Program start *) + + (* Program end *) + + (* Test cases *) + +let test1 _ = assert_equal [50;20;80;15;17;19] (createBinaryTree [[20;15;1];[20;17;0];[50;20;1];[50;80;0];[80;19;1]]) + +let test2 _ = assert_equal [1;2;null;null;3;4] (createBinaryTree [[1;2;1];[2;3;0];[3;4;1]]) + + + (* Grouping test cases *) + let suite = "Test Suite for createBinaryTree" >::: [ + + "test1" >:: test1; + "test2" >:: test2; + ] + + + (* Running the tests *) + let () = run_test_tt_main suite +end diff --git a/create_binary_tree_from_descriptions/scala_tests/MySuite.scala b/create_binary_tree_from_descriptions/scala_tests/MySuite.scala new file mode 100644 index 0000000000000000000000000000000000000000..5bb527260d106dcccc7d877a06dfcc9829304b80 --- /dev/null +++ b/create_binary_tree_from_descriptions/scala_tests/MySuite.scala @@ -0,0 +1,12 @@ + +class MySuite extends munit.FunSuite { + + test("test1") { + assertEquals(Main.createBinaryTree(List(List(20,15,1),List(20,17,0),List(50,20,1),List(50,80,0),List(80,19,1))), List(50,20,80,15,17,19)) + } + + test("test2") { + assertEquals(Main.createBinaryTree(List(List(1,2,1),List(2,3,0),List(3,4,1))), List(1,2,null,null,3,4)) + } + +} diff --git a/create_components_with_same_value/.DS_Store b/create_components_with_same_value/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0a59a79e1b6c374d4093649a2ea4dd9bb7b57550 Binary files /dev/null and b/create_components_with_same_value/.DS_Store differ diff --git a/create_components_with_same_value/haskell_tests/Main.hs b/create_components_with_same_value/haskell_tests/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..7ea615fc97e80e6d69be9210af2732aa1b3b0efb --- /dev/null +++ b/create_components_with_same_value/haskell_tests/Main.hs @@ -0,0 +1,24 @@ + +module Main where +import Test.HUnit + +--Program start + +--Program end + +-- Test cases + +test1 :: Test +test1 = TestCase (assertEqual "for (componentValue [6,2,2,2,6] [[0,1],[1,2],[1,3],[3,4]])," 2 (componentValue [6,2,2,2,6] [[0,1],[1,2],[1,3],[3,4]])) + +test2 :: Test +test2 = TestCase (assertEqual "for (componentValue [2] [])," 0 (componentValue [2] [])) + + +-- Grouping test cases +tests :: Test +tests = TestList [TestLabel "Test1" test1] + +-- Running the tests +main :: IO Counts +main = runTestTT tests diff --git a/create_components_with_same_value/java_tests/Main.java b/create_components_with_same_value/java_tests/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..fc4608e66c3b5bfbd05fcdb060385632a3277ad3 --- /dev/null +++ b/create_components_with_same_value/java_tests/Main.java @@ -0,0 +1,21 @@ + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; +public class Main { + //Program start + + //Program end + + @Test +public void test1() { + assertEquals(2, componentValue(new ArrayList<>(Arrays.asList(6,2,2,2,6)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(3,4)))))); +} +@Test +public void test2() { + assertEquals(0, componentValue(new ArrayList<>(Arrays.asList(2)), [])); +} + +}