DatasetRepo commited on
Commit
ba8e0c7
·
verified ·
1 Parent(s): c9676bd

88172528aff7d5f4b03791c78a9538bd129960bea3241db0df6269e07e50df47

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. number_of_beautiful_partitions/scala_tests/MySuite.scala +16 -0
  3. number_of_black_blocks/.DS_Store +0 -0
  4. number_of_black_blocks/haskell_tests/Main.hs +24 -0
  5. number_of_black_blocks/java_tests/Main.java +21 -0
  6. number_of_black_blocks/meta.json +0 -0
  7. number_of_black_blocks/ocaml_tests/main.ml +26 -0
  8. number_of_black_blocks/scala_tests/MySuite.scala +12 -0
  9. number_of_changing_keys/haskell_tests/Main.hs +41 -0
  10. number_of_changing_keys/java_tests/Main.java +20 -0
  11. number_of_changing_keys/meta.json +47 -0
  12. number_of_changing_keys/ocaml_tests/main.ml +42 -0
  13. number_of_changing_keys/scala_tests/MySuite.scala +32 -0
  14. number_of_common_factors/.DS_Store +0 -0
  15. number_of_common_factors/haskell_tests/Main.hs +24 -0
  16. number_of_common_factors/java_tests/Main.java +21 -0
  17. number_of_common_factors/meta.json +97 -0
  18. number_of_common_factors/ocaml_tests/main.ml +26 -0
  19. number_of_common_factors/scala_tests/MySuite.scala +12 -0
  20. number_of_distinct_averages/.DS_Store +0 -0
  21. number_of_distinct_averages/haskell_tests/Main.hs +24 -0
  22. number_of_distinct_averages/java_tests/Main.java +21 -0
  23. number_of_distinct_averages/meta.json +479 -0
  24. number_of_distinct_averages/ocaml_tests/main.ml +26 -0
  25. number_of_distinct_averages/scala_tests/MySuite.scala +12 -0
  26. number_of_employees_who_met_the_target/.DS_Store +0 -0
  27. number_of_employees_who_met_the_target/haskell_tests/Main.hs +24 -0
  28. number_of_employees_who_met_the_target/java_tests/Main.java +21 -0
  29. number_of_employees_who_met_the_target/meta.json +347 -0
  30. number_of_employees_who_met_the_target/ocaml_tests/main.ml +26 -0
  31. number_of_employees_who_met_the_target/scala_tests/MySuite.scala +12 -0
  32. number_of_excellent_pairs/.DS_Store +0 -0
  33. number_of_excellent_pairs/haskell_tests/Main.hs +24 -0
  34. number_of_excellent_pairs/java_tests/Main.java +21 -0
  35. number_of_excellent_pairs/meta.json +3 -0
  36. number_of_excellent_pairs/ocaml_tests/main.ml +26 -0
  37. number_of_excellent_pairs/scala_tests/MySuite.scala +12 -0
  38. number_of_flowers_in_full_bloom/.DS_Store +0 -0
  39. number_of_flowers_in_full_bloom/haskell_tests/Main.hs +24 -0
  40. number_of_flowers_in_full_bloom/java_tests/Main.java +21 -0
  41. number_of_flowers_in_full_bloom/meta.json +3 -0
  42. number_of_flowers_in_full_bloom/ocaml_tests/main.ml +26 -0
  43. number_of_flowers_in_full_bloom/scala_tests/MySuite.scala +12 -0
  44. number_of_good_paths/.DS_Store +0 -0
  45. number_of_good_paths/haskell_tests/Main.hs +27 -0
  46. number_of_good_paths/java_tests/Main.java +25 -0
  47. number_of_good_paths/meta.json +31 -0
  48. number_of_good_paths/ocaml_tests/main.ml +29 -0
  49. number_of_good_paths/scala_tests/MySuite.scala +16 -0
  50. number_of_great_partitions/.DS_Store +0 -0
.gitattributes CHANGED
@@ -252,3 +252,5 @@ most_popular_video_creator/meta.json filter=lfs diff=lfs merge=lfs -text
252
  movement_of_robots/meta.json filter=lfs diff=lfs merge=lfs -text
253
  next_greater_element_iv/meta.json filter=lfs diff=lfs merge=lfs -text
254
  node_with_highest_edge_score/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
252
  movement_of_robots/meta.json filter=lfs diff=lfs merge=lfs -text
253
  next_greater_element_iv/meta.json filter=lfs diff=lfs merge=lfs -text
254
  node_with_highest_edge_score/meta.json filter=lfs diff=lfs merge=lfs -text
255
+ number_of_excellent_pairs/meta.json filter=lfs diff=lfs merge=lfs -text
256
+ number_of_flowers_in_full_bloom/meta.json filter=lfs diff=lfs merge=lfs -text
number_of_beautiful_partitions/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.beautifulPartitions("23542185131",3,2), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.beautifulPartitions("23542185131",3,3), 1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.beautifulPartitions("3312958",3,1), 1)
14
+ }
15
+
16
+ }
number_of_black_blocks/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_black_blocks/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 (countBlackBlocks 3 3 [[0,0]])," [3,1,0,0,0] (countBlackBlocks 3 3 [[0,0]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countBlackBlocks 3 3 [[0,0],[1,1],[0,2]])," [0,2,2,0,0] (countBlackBlocks 3 3 [[0,0],[1,1],[0,2]]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
number_of_black_blocks/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,1,0,0,0)), countBlackBlocks(3, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,0))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0,2,2,0,0)), countBlackBlocks(3, 3, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,0)),new ArrayList<>(Arrays.asList(1,1)),new ArrayList<>(Arrays.asList(0,2))))));
19
+ }
20
+
21
+ }
number_of_black_blocks/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
number_of_black_blocks/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;1;0;0;0] (countBlackBlocks 3 3 [[0;0]])
12
+
13
+ let test2 _ = assert_equal [0;2;2;0;0] (countBlackBlocks 3 3 [[0;0];[1;1];[0;2]])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for countBlackBlocks" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_black_blocks/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countBlackBlocks(3,3,List(List(0,0))), List(3,1,0,0,0))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countBlackBlocks(3,3,List(List(0,0),List(1,1),List(0,2))), List(0,2,2,0,0))
10
+ }
11
+
12
+ }
number_of_changing_keys/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ countKeyChanges :: String -> Int
7
+ countKeyChanges s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (countKeyChanges \"aAbBcC \")," 2 (countKeyChanges "aAbBcC"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (countKeyChanges \"AaAaAaaA \")," 0 (countKeyChanges "AaAaAaaA"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (countKeyChanges \"sJZIxUDeOnkCxEKHMqCGmsEYAyjzhfcDjszMWonomvIAOhhWKixeBCxTVNbdHyKwmuAJGI \")," 68 (countKeyChanges "sJZIxUDeOnkCxEKHMqCGmsEYAyjzhfcDjszMWonomvIAOhhWKixeBCxTVNbdHyKwmuAJGI"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (countKeyChanges \"jHnOXcWJmsLiDoxSKJcrLDFbQoPUuTXaiGTTciAT \")," 37 (countKeyChanges "jHnOXcWJmsLiDoxSKJcrLDFbQoPUuTXaiGTTciAT"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (countKeyChanges \"W \")," 0 (countKeyChanges "W"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (countKeyChanges \"flr \")," 2 (countKeyChanges "flr"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (countKeyChanges \"GzkXFWdMQKSjiwbhNZgzzaebLaNnxZwvh \")," 30 (countKeyChanges "GzkXFWdMQKSjiwbhNZgzzaebLaNnxZwvh"))
33
+
34
+
35
+ -- Grouping test cases
36
+ tests :: Test
37
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6]
38
+
39
+ -- Running the tests
40
+ main :: IO Counts
41
+ main = runTestTT tests
number_of_changing_keys/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(2, countKeyChanges("aAbBcC"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(0, countKeyChanges("AaAaAaaA"));
18
+ }
19
+
20
+ }
number_of_changing_keys/meta.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3312,
3
+ "name": "number_of_changing_keys",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/number-of-changing-keys/",
6
+ "date": "2024-01-21 00:00:00",
7
+ "task_description": "You are given a **0-indexed **string `s` typed by a user. Changing a key is defined as using a key different from the last used key. For example, `s = \"ab\"` has a change of a key while `s = \"bBBb\"` does not have any. Return _the number of times the user had to change the key. _ **Note: **Modifiers like `shift` or `caps lock` won't be counted in changing the key that is if a user typed the letter `'a'` and then the letter `'A'` then it will not be considered as a changing of key. **Example 1:** ``` **Input:** s = \"aAbBcC\" **Output:** 2 **Explanation:** From s[0] = 'a' to s[1] = 'A', there is no change of key as caps lock or shift is not counted. From s[1] = 'A' to s[2] = 'b', there is a change of key. From s[2] = 'b' to s[3] = 'B', there is no change of key as caps lock or shift is not counted. From s[3] = 'B' to s[4] = 'c', there is a change of key. From s[4] = 'c' to s[5] = 'C', there is no change of key as caps lock or shift is not counted. ``` **Example 2:** ``` **Input:** s = \"AaAaAaaA\" **Output:** 0 **Explanation:** There is no change of key since only the letters 'a' and 'A' are pressed which does not require change of key. ``` **Constraints:** `1 <= s.length <= 100` `s` consists of only upper case and lower case English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"aAbBcC\"",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"AaAaAaaA\"",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "sJZIxUDeOnkCxEKHMqCGmsEYAyjzhfcDjszMWonomvIAOhhWKixeBCxTVNbdHyKwmuAJGI",
23
+ "output": 68
24
+ },
25
+ {
26
+ "input": "jHnOXcWJmsLiDoxSKJcrLDFbQoPUuTXaiGTTciAT",
27
+ "output": 37
28
+ },
29
+ {
30
+ "input": "W",
31
+ "output": 0
32
+ },
33
+ {
34
+ "input": "flr",
35
+ "output": 2
36
+ },
37
+ {
38
+ "input": "GzkXFWdMQKSjiwbhNZgzzaebLaNnxZwvh",
39
+ "output": 30
40
+ }
41
+ ],
42
+ "haskell_template": "countKeyChanges :: String -> Int\ncountKeyChanges s ",
43
+ "ocaml_template": "let countKeyChanges (s: string) : int = ",
44
+ "scala_template": "def countKeyChanges(s: String): Int = { \n \n}",
45
+ "java_template": "class Solution {\n public int countKeyChanges(String s) {\n \n }\n}",
46
+ "python_template": "class Solution(object):\n def countKeyChanges(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "
47
+ }
number_of_changing_keys/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let countKeyChanges (s: string) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 2 (countKeyChanges "aAbBcC")
13
+
14
+ let test2 _ = assert_equal 0 (countKeyChanges "AaAaAaaA")
15
+
16
+ let test3 _ = assert_equal 0 (countKeyChanges "sJZIxUDeOnkCxEKHMqCGmsEYAyjzhfcDjszMWonomvIAOhhWKixeBCxTVNbdHyKwmuAJGI")
17
+
18
+ let test4 _ = assert_equal 0 (countKeyChanges "jHnOXcWJmsLiDoxSKJcrLDFbQoPUuTXaiGTTciAT")
19
+
20
+ let test5 _ = assert_equal 0 (countKeyChanges "W")
21
+
22
+ let test6 _ = assert_equal 0 (countKeyChanges "flr")
23
+
24
+ let test7 _ = assert_equal 0 (countKeyChanges "GzkXFWdMQKSjiwbhNZgzzaebLaNnxZwvh")
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for countKeyChanges" >::: [
29
+
30
+ "test1" >:: test1;
31
+ "test2" >:: test2;
32
+ "test3" >:: test3;
33
+ "test4" >:: test4;
34
+ "test5" >:: test5;
35
+ "test6" >:: test6;
36
+ "test7" >:: test7;
37
+ ]
38
+
39
+
40
+ (* Running the tests *)
41
+ let () = run_test_tt_main suite
42
+ end
number_of_changing_keys/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countKeyChanges("aAbBcC"), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countKeyChanges("AaAaAaaA"), 0)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.countKeyChanges(",s,J,Z,I,x,U,D,e,O,n,k,C,x,E,K,H,M,q,C,G,m,s,E,Y,A,y,j,z,h,f,c,D,j,s,z,M,W,o,n,o,m,v,I,A,O,h,h,W,K,i,x,e,B,C,x,T,V,N,b,d,H,y,K,w,m,u,A,J,G,I,"), 68)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.countKeyChanges(",j,H,n,O,X,c,W,J,m,s,L,i,D,o,x,S,K,J,c,r,L,D,F,b,Q,o,P,U,u,T,X,a,i,G,T,T,c,i,A,T,"), 37)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.countKeyChanges(",W,"), 0)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.countKeyChanges(",f,l,r,"), 2)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.countKeyChanges(",G,z,k,X,F,W,d,M,Q,K,S,j,i,w,b,h,N,Z,g,z,z,a,e,b,L,a,N,n,x,Z,w,v,h,"), 30)
30
+ }
31
+
32
+ }
number_of_common_factors/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_common_factors/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 (commonFactors 12 6)," 4 (commonFactors 12 6))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (commonFactors 25 30)," 2 (commonFactors 25 30))
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
number_of_common_factors/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(4, commonFactors(12, 6));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, commonFactors(25, 30));
19
+ }
20
+
21
+ }
number_of_common_factors/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2507,
3
+ "name": "number_of_common_factors",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/number-of-common-factors/",
6
+ "date": "1664064000000",
7
+ "task_description": "Given two positive integers `a` and `b`, return _the number of **common** factors of _`a`_ and _`b`. An integer `x` is a **common factor** of `a` and `b` if `x` divides both `a` and `b`. **Example 1:** ``` **Input:** a = 12, b = 6 **Output:** 4 **Explanation:** The common factors of 12 and 6 are 1, 2, 3, 6. ``` **Example 2:** ``` **Input:** a = 25, b = 30 **Output:** 2 **Explanation:** The common factors of 25 and 30 are 1, 5. ``` **Constraints:** `1 <= a, b <= 1000`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "a = 12, b = 6",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "a = 25, b = 30",
17
+ "output": "2 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 451,
24
+ 147
25
+ ],
26
+ "output": 1
27
+ },
28
+ {
29
+ "input": [
30
+ 140,
31
+ 725
32
+ ],
33
+ "output": 2
34
+ },
35
+ {
36
+ "input": [
37
+ 640,
38
+ 81
39
+ ],
40
+ "output": 1
41
+ },
42
+ {
43
+ "input": [
44
+ 868,
45
+ 559
46
+ ],
47
+ "output": 1
48
+ },
49
+ {
50
+ "input": [
51
+ 195,
52
+ 384
53
+ ],
54
+ "output": 2
55
+ },
56
+ {
57
+ "input": [
58
+ 739,
59
+ 215
60
+ ],
61
+ "output": 1
62
+ },
63
+ {
64
+ "input": [
65
+ 103,
66
+ 422
67
+ ],
68
+ "output": 1
69
+ },
70
+ {
71
+ "input": [
72
+ 705,
73
+ 23
74
+ ],
75
+ "output": 1
76
+ },
77
+ {
78
+ "input": [
79
+ 1000,
80
+ 488
81
+ ],
82
+ "output": 4
83
+ },
84
+ {
85
+ "input": [
86
+ 202,
87
+ 862
88
+ ],
89
+ "output": 2
90
+ }
91
+ ],
92
+ "haskell_template": "commonFactors :: Int -> Int -> Int\ncommonFactors a b ",
93
+ "ocaml_template": "let commonFactors (a: int) (b: int) : int = ",
94
+ "scala_template": "def commonFactors(a: Int,b: Int): Int = { \n \n}",
95
+ "java_template": "public static int commonFactors(int a, int b) {\n\n}",
96
+ "python_template": "class Solution(object):\n def commonFactors(self, a, b):\n \"\"\"\n :type a: int\n :type b: int\n :rtype: int\n \"\"\"\n "
97
+ }
number_of_common_factors/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 4 (commonFactors 12 6)
12
+
13
+ let test2 _ = assert_equal 2 (commonFactors 25 30)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for commonFactors" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_common_factors/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.commonFactors(12,6), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.commonFactors(25,30), 2)
10
+ }
11
+
12
+ }
number_of_distinct_averages/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_distinct_averages/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 (distinctAverages [4,1,4,0,3,5])," 2 (distinctAverages [4,1,4,0,3,5]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (distinctAverages [1,100])," 1 (distinctAverages [1,100]))
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
number_of_distinct_averages/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, distinctAverages(new ArrayList<>(Arrays.asList(4,1,4,0,3,5))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, distinctAverages(new ArrayList<>(Arrays.asList(1,100))));
19
+ }
20
+
21
+ }
number_of_distinct_averages/meta.json ADDED
@@ -0,0 +1,479 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2561,
3
+ "name": "number_of_distinct_averages",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/number-of-distinct-averages/",
6
+ "date": "1667001600000",
7
+ "task_description": "You are given a **0-indexed** integer array `nums` of **even** length. As long as `nums` is **not** empty, you must repetitively: Find the minimum number in `nums` and remove it. Find the maximum number in `nums` and remove it. Calculate the average of the two removed numbers. The **average** of two numbers `a` and `b` is `(a + b) / 2`. For example, the average of `2` and `3` is `(2 + 3) / 2 = 2.5`. Return_ the number of **distinct** averages calculated using the above process_. **Note** that when there is a tie for a minimum or maximum number, any can be removed. **Example 1:** ``` **Input:** nums = [4,1,4,0,3,5] **Output:** 2 **Explanation:** 1. Remove 0 and 5, and the average is (0 + 5) / 2 = 2.5. Now, nums = [4,1,4,3]. 2. Remove 1 and 4. The average is (1 + 4) / 2 = 2.5, and nums = [4,3]. 3. Remove 3 and 4, and the average is (3 + 4) / 2 = 3.5. Since there are 2 distinct numbers among 2.5, 2.5, and 3.5, we return 2. ``` **Example 2:** ``` **Input:** nums = [1,100] **Output:** 1 **Explanation:** There is only one average to be calculated after removing 1 and 100, so we return 1. ``` **Constraints:** `2 <= nums.length <= 100` `nums.length` is even. `0 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [4,1,4,0,3,5]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,100]",
17
+ "output": "1 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 0,
24
+ 4,
25
+ 7,
26
+ 8,
27
+ 13,
28
+ 14,
29
+ 25,
30
+ 26,
31
+ 27,
32
+ 36,
33
+ 47,
34
+ 49,
35
+ 49,
36
+ 51,
37
+ 51,
38
+ 56,
39
+ 66,
40
+ 67,
41
+ 67,
42
+ 71,
43
+ 80,
44
+ 82,
45
+ 85,
46
+ 89,
47
+ 92,
48
+ 94,
49
+ 96,
50
+ 98,
51
+ 100,
52
+ 100
53
+ ],
54
+ "output": 11
55
+ },
56
+ {
57
+ "input": [
58
+ 0,
59
+ 15,
60
+ 19,
61
+ 38,
62
+ 50,
63
+ 59,
64
+ 60,
65
+ 90
66
+ ],
67
+ "output": 4
68
+ },
69
+ {
70
+ "input": [
71
+ 0,
72
+ 0,
73
+ 0,
74
+ 1,
75
+ 3,
76
+ 5,
77
+ 5,
78
+ 5,
79
+ 6,
80
+ 7,
81
+ 10,
82
+ 13,
83
+ 14,
84
+ 17,
85
+ 18,
86
+ 19,
87
+ 19,
88
+ 22,
89
+ 25,
90
+ 25,
91
+ 26,
92
+ 26,
93
+ 33,
94
+ 34,
95
+ 40,
96
+ 40,
97
+ 41,
98
+ 41,
99
+ 44,
100
+ 46,
101
+ 46,
102
+ 46,
103
+ 47,
104
+ 47,
105
+ 48,
106
+ 48,
107
+ 49,
108
+ 51,
109
+ 51,
110
+ 52,
111
+ 53,
112
+ 54,
113
+ 57,
114
+ 57,
115
+ 60,
116
+ 60,
117
+ 62,
118
+ 62,
119
+ 62,
120
+ 67,
121
+ 67,
122
+ 67,
123
+ 69,
124
+ 69,
125
+ 70,
126
+ 71,
127
+ 73,
128
+ 73,
129
+ 73,
130
+ 73,
131
+ 74,
132
+ 75,
133
+ 75,
134
+ 76,
135
+ 79,
136
+ 80,
137
+ 80,
138
+ 82,
139
+ 84,
140
+ 85,
141
+ 86,
142
+ 87,
143
+ 89,
144
+ 92,
145
+ 94,
146
+ 95,
147
+ 96,
148
+ 97,
149
+ 99,
150
+ 99,
151
+ 99,
152
+ 100
153
+ ],
154
+ "output": 16
155
+ },
156
+ {
157
+ "input": [
158
+ 4,
159
+ 31,
160
+ 34,
161
+ 49,
162
+ 50,
163
+ 51,
164
+ 63,
165
+ 67,
166
+ 76,
167
+ 88,
168
+ 88,
169
+ 88,
170
+ 94,
171
+ 99
172
+ ],
173
+ "output": 7
174
+ },
175
+ {
176
+ "input": [
177
+ 5,
178
+ 8,
179
+ 13,
180
+ 14,
181
+ 16,
182
+ 17,
183
+ 18,
184
+ 19,
185
+ 26,
186
+ 26,
187
+ 28,
188
+ 33,
189
+ 34,
190
+ 38,
191
+ 46,
192
+ 49,
193
+ 50,
194
+ 50,
195
+ 51,
196
+ 56,
197
+ 57,
198
+ 57,
199
+ 64,
200
+ 66,
201
+ 67,
202
+ 69,
203
+ 71,
204
+ 71,
205
+ 73,
206
+ 75,
207
+ 76,
208
+ 83,
209
+ 87,
210
+ 87,
211
+ 87,
212
+ 98
213
+ ],
214
+ "output": 10
215
+ },
216
+ {
217
+ "input": [
218
+ 11,
219
+ 13,
220
+ 13,
221
+ 19,
222
+ 31,
223
+ 33,
224
+ 45,
225
+ 47,
226
+ 47,
227
+ 51,
228
+ 62,
229
+ 84,
230
+ 87,
231
+ 89
232
+ ],
233
+ "output": 6
234
+ },
235
+ {
236
+ "input": [
237
+ 0,
238
+ 1,
239
+ 3,
240
+ 3,
241
+ 6,
242
+ 6,
243
+ 7,
244
+ 8,
245
+ 9,
246
+ 9,
247
+ 14,
248
+ 17,
249
+ 18,
250
+ 18,
251
+ 20,
252
+ 22,
253
+ 24,
254
+ 25,
255
+ 28,
256
+ 28,
257
+ 29,
258
+ 29,
259
+ 30,
260
+ 31,
261
+ 32,
262
+ 32,
263
+ 33,
264
+ 36,
265
+ 38,
266
+ 38,
267
+ 39,
268
+ 40,
269
+ 41,
270
+ 43,
271
+ 43,
272
+ 46,
273
+ 52,
274
+ 52,
275
+ 55,
276
+ 57,
277
+ 57,
278
+ 57,
279
+ 60,
280
+ 61,
281
+ 61,
282
+ 64,
283
+ 66,
284
+ 68,
285
+ 68,
286
+ 69,
287
+ 70,
288
+ 71,
289
+ 72,
290
+ 73,
291
+ 73,
292
+ 77,
293
+ 79,
294
+ 79,
295
+ 80,
296
+ 80,
297
+ 81,
298
+ 82,
299
+ 84,
300
+ 89,
301
+ 90,
302
+ 90,
303
+ 91,
304
+ 97,
305
+ 100,
306
+ 100
307
+ ],
308
+ "output": 13
309
+ },
310
+ {
311
+ "input": [
312
+ 12,
313
+ 26,
314
+ 30,
315
+ 34,
316
+ 35,
317
+ 36,
318
+ 38,
319
+ 39,
320
+ 42,
321
+ 44,
322
+ 63,
323
+ 64,
324
+ 68,
325
+ 68,
326
+ 77,
327
+ 79,
328
+ 90,
329
+ 98,
330
+ 100,
331
+ 100
332
+ ],
333
+ "output": 8
334
+ },
335
+ {
336
+ "input": [
337
+ 0,
338
+ 0,
339
+ 1,
340
+ 2,
341
+ 5,
342
+ 6,
343
+ 7,
344
+ 9,
345
+ 11,
346
+ 13,
347
+ 13,
348
+ 13,
349
+ 14,
350
+ 15,
351
+ 15,
352
+ 16,
353
+ 18,
354
+ 18,
355
+ 19,
356
+ 20,
357
+ 20,
358
+ 23,
359
+ 23,
360
+ 24,
361
+ 24,
362
+ 26,
363
+ 26,
364
+ 27,
365
+ 27,
366
+ 28,
367
+ 28,
368
+ 28,
369
+ 29,
370
+ 31,
371
+ 31,
372
+ 32,
373
+ 34,
374
+ 34,
375
+ 35,
376
+ 36,
377
+ 39,
378
+ 39,
379
+ 41,
380
+ 41,
381
+ 43,
382
+ 43,
383
+ 44,
384
+ 44,
385
+ 45,
386
+ 47,
387
+ 48,
388
+ 49,
389
+ 49,
390
+ 52,
391
+ 56,
392
+ 56,
393
+ 57,
394
+ 58,
395
+ 59,
396
+ 60,
397
+ 60,
398
+ 61,
399
+ 62,
400
+ 64,
401
+ 65,
402
+ 67,
403
+ 67,
404
+ 70,
405
+ 71,
406
+ 71,
407
+ 72,
408
+ 72,
409
+ 72,
410
+ 73,
411
+ 77,
412
+ 78,
413
+ 78,
414
+ 78,
415
+ 81,
416
+ 82,
417
+ 84,
418
+ 84,
419
+ 84,
420
+ 85,
421
+ 86,
422
+ 86,
423
+ 87,
424
+ 88,
425
+ 88,
426
+ 89,
427
+ 90,
428
+ 91,
429
+ 92,
430
+ 93,
431
+ 94,
432
+ 95,
433
+ 98,
434
+ 99,
435
+ 100,
436
+ 100
437
+ ],
438
+ "output": 12
439
+ },
440
+ {
441
+ "input": [
442
+ 0,
443
+ 5,
444
+ 22,
445
+ 22,
446
+ 24,
447
+ 27,
448
+ 32,
449
+ 32,
450
+ 33,
451
+ 37,
452
+ 37,
453
+ 37,
454
+ 43,
455
+ 45,
456
+ 50,
457
+ 59,
458
+ 60,
459
+ 64,
460
+ 69,
461
+ 72,
462
+ 75,
463
+ 77,
464
+ 77,
465
+ 87,
466
+ 89,
467
+ 91,
468
+ 95,
469
+ 98
470
+ ],
471
+ "output": 13
472
+ }
473
+ ],
474
+ "haskell_template": "distinctAverages :: [Int] -> Int\ndistinctAverages nums ",
475
+ "ocaml_template": "let distinctAverages (nums: int list) : int = ",
476
+ "scala_template": "def distinctAverages(nums: List[Int]): Int = { \n \n}",
477
+ "java_template": "public static int distinctAverages(List<Integer> nums) {\n\n}",
478
+ "python_template": "class Solution(object):\n def distinctAverages(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
479
+ }
number_of_distinct_averages/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 (distinctAverages [4;1;4;0;3;5])
12
+
13
+ let test2 _ = assert_equal 1 (distinctAverages [1;100])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for distinctAverages" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_distinct_averages/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.distinctAverages(List(4,1,4,0,3,5)), 2)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.distinctAverages(List(1,100)), 1)
10
+ }
11
+
12
+ }
number_of_employees_who_met_the_target/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_employees_who_met_the_target/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 (numberOfEmployeesWhoMetTarget [0,1,2,3,4] 2)," 3 (numberOfEmployeesWhoMetTarget [0,1,2,3,4] 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (numberOfEmployeesWhoMetTarget [5,1,4,2,2] 6)," 0 (numberOfEmployeesWhoMetTarget [5,1,4,2,2] 6))
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
number_of_employees_who_met_the_target/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, numberOfEmployeesWhoMetTarget(new ArrayList<>(Arrays.asList(0,1,2,3,4)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, numberOfEmployeesWhoMetTarget(new ArrayList<>(Arrays.asList(5,1,4,2,2)), 6));
19
+ }
20
+
21
+ }
number_of_employees_who_met_the_target/meta.json ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2876,
3
+ "name": "number_of_employees_who_met_the_target",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/number-of-employees-who-met-the-target/",
6
+ "date": "1690070400000",
7
+ "task_description": "There are `n` employees in a company, numbered from `0` to `n - 1`. Each employee `i` has worked for `hours[i]` hours in the company. The company requires each employee to work for **at least** `target` hours. You are given a **0-indexed** array of non-negative integers `hours` of length `n` and a non-negative integer `target`. Return _the integer denoting the number of employees who worked at least_ `target` _hours_. **Example 1:** ``` **Input:** hours = [0,1,2,3,4], target = 2 **Output:** 3 **Explanation:** The company wants each employee to work for at least 2 hours. - Employee 0 worked for 0 hours and didn't meet the target. - Employee 1 worked for 1 hours and didn't meet the target. - Employee 2 worked for 2 hours and met the target. - Employee 3 worked for 3 hours and met the target. - Employee 4 worked for 4 hours and met the target. There are 3 employees who met the target. ``` **Example 2:** ``` **Input:** hours = [5,1,4,2,2], target = 6 **Output:** 0 **Explanation:** The company wants each employee to work for at least 6 hours. There are 0 employees who met the target. ``` **Constraints:** `1 <= n == hours.length <= 50` `0 <= hours[i], target <= 105`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "hours = [0,1,2,3,4], target = 2",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "hours = [5,1,4,2,2], target = 6",
17
+ "output": "0 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ [
24
+ 26917,
25
+ 92767,
26
+ 61431,
27
+ 74806,
28
+ 62926,
29
+ 47142,
30
+ 81802,
31
+ 33945,
32
+ 17936,
33
+ 3127,
34
+ 80442,
35
+ 72513,
36
+ 55219,
37
+ 19560,
38
+ 4846,
39
+ 57181,
40
+ 66197,
41
+ 75253,
42
+ 16470,
43
+ 56002,
44
+ 32785,
45
+ 67789,
46
+ 64751
47
+ ],
48
+ 25375
49
+ ],
50
+ "output": 18
51
+ },
52
+ {
53
+ "input": [
54
+ [
55
+ 91734,
56
+ 99799,
57
+ 4973,
58
+ 36005,
59
+ 15972,
60
+ 31666,
61
+ 96819,
62
+ 81346,
63
+ 19824,
64
+ 17733,
65
+ 43540,
66
+ 69278,
67
+ 86840,
68
+ 81515,
69
+ 23413,
70
+ 9162,
71
+ 7830,
72
+ 83574,
73
+ 31740,
74
+ 87579
75
+ ],
76
+ 6580
77
+ ],
78
+ "output": 19
79
+ },
80
+ {
81
+ "input": [
82
+ [
83
+ 74683,
84
+ 36319,
85
+ 79579,
86
+ 86033,
87
+ 76201,
88
+ 80994,
89
+ 71665,
90
+ 28663,
91
+ 14183,
92
+ 63717,
93
+ 76869,
94
+ 79525,
95
+ 80989,
96
+ 99451,
97
+ 63658,
98
+ 57250,
99
+ 56787,
100
+ 11839,
101
+ 23699,
102
+ 51417,
103
+ 77492,
104
+ 96168,
105
+ 40320,
106
+ 36123,
107
+ 56847,
108
+ 94294,
109
+ 41900,
110
+ 23089,
111
+ 51307,
112
+ 8472,
113
+ 73762,
114
+ 94425,
115
+ 89210,
116
+ 7617,
117
+ 94791,
118
+ 88354,
119
+ 55028,
120
+ 64448,
121
+ 15448
122
+ ],
123
+ 44885
124
+ ],
125
+ "output": 27
126
+ },
127
+ {
128
+ "input": [
129
+ [
130
+ 65916,
131
+ 8703,
132
+ 66184,
133
+ 28441,
134
+ 83616,
135
+ 22076,
136
+ 40445,
137
+ 42679,
138
+ 6859,
139
+ 79231,
140
+ 86029,
141
+ 97690,
142
+ 73580,
143
+ 65065,
144
+ 29443
145
+ ],
146
+ 77088
147
+ ],
148
+ "output": 4
149
+ },
150
+ {
151
+ "input": [
152
+ [
153
+ 9441,
154
+ 26850,
155
+ 60165,
156
+ 91173,
157
+ 37030,
158
+ 70999,
159
+ 27344,
160
+ 46359,
161
+ 89289,
162
+ 22985,
163
+ 31896,
164
+ 62574,
165
+ 88562,
166
+ 67360,
167
+ 84090,
168
+ 94337,
169
+ 88394,
170
+ 10468,
171
+ 32070,
172
+ 584,
173
+ 63971,
174
+ 96386,
175
+ 30715,
176
+ 16099,
177
+ 97357,
178
+ 293,
179
+ 15022,
180
+ 7715,
181
+ 30134,
182
+ 55366,
183
+ 51435,
184
+ 49687,
185
+ 54200,
186
+ 5973,
187
+ 31674
188
+ ],
189
+ 56131
190
+ ],
191
+ "output": 13
192
+ },
193
+ {
194
+ "input": [
195
+ [
196
+ 23886
197
+ ],
198
+ 61735
199
+ ],
200
+ "output": 0
201
+ },
202
+ {
203
+ "input": [
204
+ [
205
+ 4531,
206
+ 53926,
207
+ 40178,
208
+ 16515,
209
+ 68987,
210
+ 10853,
211
+ 66827,
212
+ 79486,
213
+ 25200,
214
+ 7178,
215
+ 37636,
216
+ 83521,
217
+ 89341,
218
+ 15266,
219
+ 60264,
220
+ 96601,
221
+ 47135
222
+ ],
223
+ 1361
224
+ ],
225
+ "output": 17
226
+ },
227
+ {
228
+ "input": [
229
+ [
230
+ 34258,
231
+ 26662,
232
+ 92204,
233
+ 44479,
234
+ 60627,
235
+ 84482,
236
+ 59348,
237
+ 50092,
238
+ 73337,
239
+ 51045,
240
+ 87274,
241
+ 46163,
242
+ 36945,
243
+ 49889,
244
+ 45688,
245
+ 98137,
246
+ 5112,
247
+ 89521,
248
+ 94524,
249
+ 84627,
250
+ 5578,
251
+ 70687,
252
+ 79808,
253
+ 57000,
254
+ 74736,
255
+ 11118,
256
+ 25779,
257
+ 75000,
258
+ 4286,
259
+ 73949,
260
+ 58701,
261
+ 79512,
262
+ 7977,
263
+ 46955,
264
+ 65559,
265
+ 60435,
266
+ 32621,
267
+ 77694,
268
+ 90878,
269
+ 74586,
270
+ 42780,
271
+ 56347,
272
+ 30134,
273
+ 15356
274
+ ],
275
+ 60715
276
+ ],
277
+ "output": 18
278
+ },
279
+ {
280
+ "input": [
281
+ [
282
+ 54001,
283
+ 71506,
284
+ 98124,
285
+ 45961,
286
+ 14470,
287
+ 23848,
288
+ 53852,
289
+ 59341,
290
+ 47118,
291
+ 94202,
292
+ 50707,
293
+ 72585,
294
+ 54343,
295
+ 75678,
296
+ 18310,
297
+ 90558,
298
+ 44936,
299
+ 66177,
300
+ 76314,
301
+ 33403,
302
+ 64742,
303
+ 10682,
304
+ 18433,
305
+ 18783,
306
+ 86658,
307
+ 73317,
308
+ 15603,
309
+ 25316,
310
+ 32229,
311
+ 71021,
312
+ 87941,
313
+ 1224,
314
+ 28861,
315
+ 6609,
316
+ 96871,
317
+ 5584,
318
+ 6816,
319
+ 98740
320
+ ],
321
+ 25768
322
+ ],
323
+ "output": 26
324
+ },
325
+ {
326
+ "input": [
327
+ [
328
+ 49912,
329
+ 81144,
330
+ 39422,
331
+ 28821,
332
+ 71772,
333
+ 49029,
334
+ 90561,
335
+ 24982
336
+ ],
337
+ 68166
338
+ ],
339
+ "output": 3
340
+ }
341
+ ],
342
+ "haskell_template": "numberOfEmployeesWhoMetTarget :: [Int] -> Int -> Int\nnumberOfEmployeesWhoMetTarget hours target ",
343
+ "ocaml_template": "let numberOfEmployeesWhoMetTarget (hours: int list) (target: int) : int = ",
344
+ "scala_template": "def numberOfEmployeesWhoMetTarget(hours: List[Int],target: Int): Int = { \n \n}",
345
+ "java_template": "public static int numberOfEmployeesWhoMetTarget(List<Integer> hours, int target) {\n\n}",
346
+ "python_template": "class Solution(object):\n def numberOfEmployeesWhoMetTarget(self, hours, target):\n \"\"\"\n :type hours: List[int]\n :type target: int\n :rtype: int\n \"\"\"\n "
347
+ }
number_of_employees_who_met_the_target/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 (numberOfEmployeesWhoMetTarget [0;1;2;3;4] 2)
12
+
13
+ let test2 _ = assert_equal 0 (numberOfEmployeesWhoMetTarget [5;1;4;2;2] 6)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for numberOfEmployeesWhoMetTarget" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_employees_who_met_the_target/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.numberOfEmployeesWhoMetTarget(List(0,1,2,3,4),2), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.numberOfEmployeesWhoMetTarget(List(5,1,4,2,2),6), 0)
10
+ }
11
+
12
+ }
number_of_excellent_pairs/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_excellent_pairs/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 (countExcellentPairs [1,2,3,1] 3)," 5 (countExcellentPairs [1,2,3,1] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (countExcellentPairs [5,1,1] 10)," 0 (countExcellentPairs [5,1,1] 10))
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
number_of_excellent_pairs/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(5, countExcellentPairs(new ArrayList<>(Arrays.asList(1,2,3,1)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(0, countExcellentPairs(new ArrayList<>(Arrays.asList(5,1,1)), 10));
19
+ }
20
+
21
+ }
number_of_excellent_pairs/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af131f41ed8d6981741047b397611fbd56ec6327789b4fffe28a85b13f7db70b
3
+ size 18351530
number_of_excellent_pairs/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 5 (countExcellentPairs [1;2;3;1] 3)
12
+
13
+ let test2 _ = assert_equal 0 (countExcellentPairs [5;1;1] 10)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for countExcellentPairs" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_excellent_pairs/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.countExcellentPairs(List(1,2,3,1),3), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.countExcellentPairs(List(5,1,1),10), 0)
10
+ }
11
+
12
+ }
number_of_flowers_in_full_bloom/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_flowers_in_full_bloom/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 (fullBloomFlowers [[1,6],[3,7],[9,12],[4,13]] [2,3,7,11])," [1,2,2,2] (fullBloomFlowers [[1,6],[3,7],[9,12],[4,13]] [2,3,7,11]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (fullBloomFlowers [[1,10],[3,3]] [3,3,2])," [2,2,1] (fullBloomFlowers [[1,10],[3,3]] [3,3,2]))
16
+
17
+
18
+ -- Grouping test cases
19
+ tests :: Test
20
+ tests = TestList [TestLabel "Test1" test1]
21
+
22
+ -- Running the tests
23
+ main :: IO Counts
24
+ main = runTestTT tests
number_of_flowers_in_full_bloom/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(1,2,2,2)), fullBloomFlowers(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,6)),new ArrayList<>(Arrays.asList(3,7)),new ArrayList<>(Arrays.asList(9,12)),new ArrayList<>(Arrays.asList(4,13)))), new ArrayList<>(Arrays.asList(2,3,7,11))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(2,2,1)), fullBloomFlowers(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,10)),new ArrayList<>(Arrays.asList(3,3)))), new ArrayList<>(Arrays.asList(3,3,2))));
19
+ }
20
+
21
+ }
number_of_flowers_in_full_bloom/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7445c69ce5172b671edf8bdfd63472704d6a799470a64e7c2f1299a7e98e850f
3
+ size 39964920
number_of_flowers_in_full_bloom/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 [1;2;2;2] (fullBloomFlowers [[1;6];[3;7];[9;12];[4;13]] [2;3;7;11])
12
+
13
+ let test2 _ = assert_equal [2;2;1] (fullBloomFlowers [[1;10];[3;3]] [3;3;2])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for fullBloomFlowers" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
number_of_flowers_in_full_bloom/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.fullBloomFlowers(List(List(1,6),List(3,7),List(9,12),List(4,13)),List(2,3,7,11)), List(1,2,2,2))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.fullBloomFlowers(List(List(1,10),List(3,3)),List(3,3,2)), List(2,2,1))
10
+ }
11
+
12
+ }
number_of_good_paths/.DS_Store ADDED
Binary file (6.15 kB). View file
 
number_of_good_paths/haskell_tests/Main.hs ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (numberOfGoodPaths [1,3,2,1,3] [[0,1],[0,2],[2,3],[2,4]])," 6 (numberOfGoodPaths [1,3,2,1,3] [[0,1],[0,2],[2,3],[2,4]]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (numberOfGoodPaths [1,1,2,2,3] [[0,1],[1,2],[2,3],[2,4]])," 7 (numberOfGoodPaths [1,1,2,2,3] [[0,1],[1,2],[2,3],[2,4]]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (numberOfGoodPaths [1] [])," 1 (numberOfGoodPaths [1] []))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
number_of_good_paths/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(6, numberOfGoodPaths(new ArrayList<>(Arrays.asList(1,3,2,1,3)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(0,2)),new ArrayList<>(Arrays.asList(2,3)),new ArrayList<>(Arrays.asList(2,4))))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(7, numberOfGoodPaths(new ArrayList<>(Arrays.asList(1,1,2,2,3)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1)),new ArrayList<>(Arrays.asList(1,2)),new ArrayList<>(Arrays.asList(2,3)),new ArrayList<>(Arrays.asList(2,4))))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(1, numberOfGoodPaths(new ArrayList<>(Arrays.asList(1)), []));
23
+ }
24
+
25
+ }
number_of_good_paths/meta.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2505,
3
+ "name": "number_of_good_paths",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/number-of-good-paths/",
6
+ "date": "1663459200000",
7
+ "task_description": "There is a tree (i.e. a connected, undirected graph with no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` edges. You are given a **0-indexed** integer array `vals` of length `n` where `vals[i]` denotes the value of the `ith` node. You are also given a 2D integer array `edges` where `edges[i] = [ai, bi]` denotes that there exists an **undirected** edge connecting nodes `ai` and `bi`. A **good path** is a simple path that satisfies the following conditions: The starting node and the ending node have the **same** value. All nodes between the starting node and the ending node have values **less than or equal to** the starting node (i.e. the starting node's value should be the maximum value along the path). Return _the number of distinct good paths_. Note that a path and its reverse are counted as the **same** path. For example, `0 -> 1` is considered to be the same as `1 -> 0`. A single node is also considered as a valid path. **Example 1:** ``` **Input:** vals = [1,3,2,1,3], edges = [[0,1],[0,2],[2,3],[2,4]] **Output:** 6 **Explanation:** There are 5 good paths consisting of a single node. There is 1 additional good path: 1 -> 0 -> 2 -> 4. (The reverse path 4 -> 2 -> 0 -> 1 is treated as the same as 1 -> 0 -> 2 -> 4.) Note that 0 -> 2 -> 3 is not a good path because vals[2] > vals[0]. ``` **Example 2:** ``` **Input:** vals = [1,1,2,2,3], edges = [[0,1],[1,2],[2,3],[2,4]] **Output:** 7 **Explanation:** There are 5 good paths consisting of a single node. There are 2 additional good paths: 0 -> 1 and 2 -> 3. ``` **Example 3:** ``` **Input:** vals = [1], edges = [] **Output:** 1 **Explanation:** The tree consists of only one node, so there is one good path. ``` **Constraints:** `n == vals.length` `1 <= n <= 3 * 104` `0 <= vals[i] <= 105` `edges.length == n - 1` `edges[i].length == 2` `0 <= ai, bi < n` `ai != bi` `edges` represents a valid tree.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "vals = [1,3,2,1,3], edges = [[0,1],[0,2],[2,3],[2,4]]",
12
+ "output": "6 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "vals = [1,1,2,2,3], edges = [[0,1],[1,2],[2,3],[2,4]]",
17
+ "output": "7 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "vals = [1], edges = []",
22
+ "output": "1 "
23
+ }
24
+ ],
25
+ "private_test_cases": [],
26
+ "haskell_template": "numberOfGoodPaths :: [Int] -> [[Int]] -> Int\nnumberOfGoodPaths vals edges ",
27
+ "ocaml_template": "let numberOfGoodPaths (vals: int list) (edges: int list list) : int = ",
28
+ "scala_template": "def numberOfGoodPaths(vals: List[Int],edges: List[List[Int]]): Int = { \n \n}",
29
+ "java_template": "public static int numberOfGoodPaths(List<Integer> vals, List<List<Integer>> edges) {\n\n}",
30
+ "python_template": "class Solution(object):\n def numberOfGoodPaths(self, vals, edges):\n \"\"\"\n :type vals: List[int]\n :type edges: List[List[int]]\n :rtype: int\n \"\"\"\n "
31
+ }
number_of_good_paths/ocaml_tests/main.ml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 6 (numberOfGoodPaths [1;3;2;1;3] [[0;1];[0;2];[2;3];[2;4]])
12
+
13
+ let test2 _ = assert_equal 7 (numberOfGoodPaths [1;1;2;2;3] [[0;1];[1;2];[2;3];[2;4]])
14
+
15
+ let test3 _ = assert_equal 1 (numberOfGoodPaths [1] [])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for numberOfGoodPaths" >::: [
20
+
21
+ "test1" >:: test1;
22
+ "test2" >:: test2;
23
+ "test3" >:: test3;
24
+ ]
25
+
26
+
27
+ (* Running the tests *)
28
+ let () = run_test_tt_main suite
29
+ end
number_of_good_paths/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.numberOfGoodPaths(List(1,3,2,1,3),List(List(0,1),List(0,2),List(2,3),List(2,4))), 6)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.numberOfGoodPaths(List(1,1,2,2,3),List(List(0,1),List(1,2),List(2,3),List(2,4))), 7)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.numberOfGoodPaths(List(1),List()), 1)
14
+ }
15
+
16
+ }
number_of_great_partitions/.DS_Store ADDED
Binary file (6.15 kB). View file