300d9c548d0181e06510a93bf2caf000732c135de434e68f028f2cbbc52f3eaa
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- number_of_subarrays_with_lcm_equal_to_k/meta.json +0 -0
- number_of_subarrays_with_lcm_equal_to_k/ocaml_tests/main.ml +26 -0
- number_of_subarrays_with_lcm_equal_to_k/scala_tests/MySuite.scala +12 -0
- number_of_valid_clock_times/.DS_Store +0 -0
- number_of_valid_clock_times/haskell_tests/Main.hs +27 -0
- number_of_valid_clock_times/java_tests/Main.java +25 -0
- number_of_valid_clock_times/meta.json +72 -0
- number_of_valid_clock_times/ocaml_tests/main.ml +29 -0
- number_of_valid_clock_times/scala_tests/MySuite.scala +16 -0
- number_of_ways_to_buy_pens_and_pencils/.DS_Store +0 -0
- number_of_ways_to_buy_pens_and_pencils/haskell_tests/Main.hs +24 -0
- number_of_ways_to_buy_pens_and_pencils/java_tests/Main.java +21 -0
- number_of_ways_to_buy_pens_and_pencils/meta.json +107 -0
- number_of_ways_to_buy_pens_and_pencils/ocaml_tests/main.ml +26 -0
- number_of_ways_to_buy_pens_and_pencils/scala_tests/MySuite.scala +12 -0
- number_of_ways_to_divide_a_long_corridor/.DS_Store +0 -0
- number_of_ways_to_divide_a_long_corridor/haskell_tests/Main.hs +27 -0
- number_of_ways_to_divide_a_long_corridor/java_tests/Main.java +25 -0
- number_of_ways_to_divide_a_long_corridor/meta.json +72 -0
- number_of_ways_to_divide_a_long_corridor/ocaml_tests/main.ml +29 -0
- number_of_ways_to_divide_a_long_corridor/scala_tests/MySuite.scala +16 -0
- number_of_ways_to_earn_points/.DS_Store +0 -0
- number_of_ways_to_earn_points/haskell_tests/Main.hs +27 -0
- number_of_ways_to_earn_points/java_tests/Main.java +25 -0
- number_of_ways_to_earn_points/meta.json +1300 -0
- number_of_ways_to_earn_points/ocaml_tests/main.ml +29 -0
- number_of_ways_to_earn_points/scala_tests/MySuite.scala +16 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/.DS_Store +0 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/haskell_tests/Main.hs +24 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/java_tests/Main.java +21 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/meta.json +107 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/ocaml_tests/main.ml +26 -0
- number_of_ways_to_reach_a_position_after_exactly_k_steps/scala_tests/MySuite.scala +12 -0
- number_of_ways_to_select_buildings/.DS_Store +0 -0
- number_of_ways_to_select_buildings/haskell_tests/Main.hs +24 -0
- number_of_ways_to_select_buildings/java_tests/Main.java +21 -0
- number_of_ways_to_select_buildings/meta.json +0 -0
- number_of_ways_to_select_buildings/ocaml_tests/main.ml +26 -0
- number_of_ways_to_select_buildings/scala_tests/MySuite.scala +12 -0
- number_of_ways_to_split_array/haskell_tests/Main.hs +0 -0
- number_of_ways_to_split_array/java_tests/Main.java +20 -0
- number_of_ways_to_split_array/meta.json +0 -0
- number_of_ways_to_split_array/ocaml_tests/main.ml +0 -0
- number_of_ways_to_split_array/scala_tests/MySuite.scala +0 -0
- number_of_zero_filled_subarrays/.DS_Store +0 -0
- number_of_zero_filled_subarrays/haskell_tests/Main.hs +27 -0
- number_of_zero_filled_subarrays/java_tests/Main.java +25 -0
- number_of_zero_filled_subarrays/meta.json +3 -0
- number_of_zero_filled_subarrays/ocaml_tests/main.ml +29 -0
.gitattributes
CHANGED
|
@@ -257,3 +257,4 @@ number_of_flowers_in_full_bloom/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
| 257 |
number_of_increasing_paths_in_a_grid/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 258 |
number_of_increasing_paths_in_a_grid/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 259 |
number_of_pairs_satisfying_inequality/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 257 |
number_of_increasing_paths_in_a_grid/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 258 |
number_of_increasing_paths_in_a_grid/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 259 |
number_of_pairs_satisfying_inequality/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 260 |
+
number_of_zero_filled_subarrays/meta.json filter=lfs diff=lfs merge=lfs -text
|
number_of_subarrays_with_lcm_equal_to_k/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_subarrays_with_lcm_equal_to_k/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 (subarrayLCM [3;6;2;7;1] 6)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 0 (subarrayLCM [3] 2)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for subarrayLCM" >::: [
|
| 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_subarrays_with_lcm_equal_to_k/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.subarrayLCM(List(3,6,2,7,1),6), 4)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.subarrayLCM(List(3),2), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_valid_clock_times/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_valid_clock_times/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 (countTime \"?5:00 \")," 2 (countTime "?5:00"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (countTime \"0?:0? \")," 100 (countTime "0?:0?"))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (countTime \"??:?? \")," 1440 (countTime "??:??"))
|
| 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_valid_clock_times/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(2, countTime("?5:00"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(100, countTime("0?:0?"));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(1440, countTime("??:??"));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
number_of_valid_clock_times/meta.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2528,
|
| 3 |
+
"name": "number_of_valid_clock_times",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-valid-clock-times/",
|
| 6 |
+
"date": "1664582400000",
|
| 7 |
+
"task_description": "You are given a string of length `5` called `time`, representing the current time on a digital clock in the format `\"hh:mm\"`. The **earliest** possible time is `\"00:00\"` and the **latest** possible time is `\"23:59\"`. In the string `time`, the digits represented by the `?` symbol are **unknown**, and must be **replaced** with a digit from `0` to `9`. Return_ an integer _`answer`_, the number of valid clock times that can be created by replacing every _`?`_ with a digit from _`0`_ to _`9`. **Example 1:** ``` **Input:** time = \"?5:00\" **Output:** 2 **Explanation:** We can replace the ? with either a 0 or 1, producing \"05:00\" or \"15:00\". Note that we cannot replace it with a 2, since the time \"25:00\" is invalid. In total, we have two choices. ``` **Example 2:** ``` **Input:** time = \"0?:0?\" **Output:** 100 **Explanation:** Each ? can be replaced by any digit from 0 to 9, so we have 100 total choices. ``` **Example 3:** ``` **Input:** time = \"??:??\" **Output:** 1440 **Explanation:** There are 24 possible choices for the hours, and 60 possible choices for the minutes. In total, we have 24 * 60 = 1440 choices. ``` **Constraints:** `time` is a valid string of length `5` in the format `\"hh:mm\"`. `\"00\" <= hh <= \"23\"` `\"00\" <= mm <= \"59\"` Some of the digits might be replaced with `'?'` and need to be replaced with digits from `0` to `9`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "time = \"?5:00\"",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "time = \"0?:0?\"",
|
| 17 |
+
"output": "100 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "time = \"??:??\"",
|
| 22 |
+
"output": "1440 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": "\"0?:??\"",
|
| 28 |
+
"output": 600
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"input": "\"00:00\"",
|
| 32 |
+
"output": 1
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": "\"?0:00\"",
|
| 36 |
+
"output": 3
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": "\"00:0?\"",
|
| 40 |
+
"output": 10
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": "\"??:?0\"",
|
| 44 |
+
"output": 144
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"input": "\"?0:00\"",
|
| 48 |
+
"output": 3
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"input": "00:?0",
|
| 52 |
+
"output": 6
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": "?0:0?",
|
| 56 |
+
"output": 30
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": "??:0?",
|
| 60 |
+
"output": 240
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"input": "00:?0",
|
| 64 |
+
"output": 6
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"haskell_template": "countTime :: String -> Int\ncountTime time ",
|
| 68 |
+
"ocaml_template": "let countTime (time: string) : int = ",
|
| 69 |
+
"scala_template": "def countTime(time: String): Int = { \n \n}",
|
| 70 |
+
"java_template": "public static int countTime(String time) {\n\n}",
|
| 71 |
+
"python_template": "class Solution(object):\n def countTime(self, time):\n \"\"\"\n :type time: str\n :rtype: int\n \"\"\"\n "
|
| 72 |
+
}
|
number_of_valid_clock_times/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 2 (countTime "?5:00")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 100 (countTime "0?:0?")
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 1440 (countTime "??:??")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for countTime" >::: [
|
| 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_valid_clock_times/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countTime("?5:00"), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countTime("0?:0?"), 100)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countTime("??:??"), 1440)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
number_of_ways_to_buy_pens_and_pencils/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_ways_to_buy_pens_and_pencils/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 (waysToBuyPensPencils 20 10 5)," 9 (waysToBuyPensPencils 20 10 5))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (waysToBuyPensPencils 5 10 10)," 1 (waysToBuyPensPencils 5 10 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_ways_to_buy_pens_and_pencils/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(9, waysToBuyPensPencils(20, 10, 5));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, waysToBuyPensPencils(5, 10, 10));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
number_of_ways_to_buy_pens_and_pencils/meta.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2351,
|
| 3 |
+
"name": "number_of_ways_to_buy_pens_and_pencils",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-ways-to-buy-pens-and-pencils/",
|
| 6 |
+
"date": "1648857600000",
|
| 7 |
+
"task_description": "You are given an integer `total` indicating the amount of money you have. You are also given two integers `cost1` and `cost2` indicating the price of a pen and pencil respectively. You can spend **part or all** of your money to buy multiple quantities (or none) of each kind of writing utensil. Return _the **number of distinct ways** you can buy some number of pens and pencils._ **Example 1:** ``` **Input:** total = 20, cost1 = 10, cost2 = 5 **Output:** 9 **Explanation:** The price of a pen is 10 and the price of a pencil is 5. - If you buy 0 pens, you can buy 0, 1, 2, 3, or 4 pencils. - If you buy 1 pen, you can buy 0, 1, or 2 pencils. - If you buy 2 pens, you cannot buy any pencils. The total number of ways to buy pens and pencils is 5 + 3 + 1 = 9. ``` **Example 2:** ``` **Input:** total = 5, cost1 = 10, cost2 = 10 **Output:** 1 **Explanation:** The price of both pens and pencils are 10, which cost more than total, so you cannot buy any writing utensils. Therefore, there is only 1 way: buy 0 pens and 0 pencils. ``` **Constraints:** `1 <= total, cost1, cost2 <= 106`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "total = 20, cost1 = 10, cost2 = 5",
|
| 12 |
+
"output": "9 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "total = 5, cost1 = 10, cost2 = 10",
|
| 17 |
+
"output": "1 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
871631,
|
| 24 |
+
186467,
|
| 25 |
+
13636
|
| 26 |
+
],
|
| 27 |
+
"output": 185
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"input": [
|
| 31 |
+
423637,
|
| 32 |
+
960136,
|
| 33 |
+
274492
|
| 34 |
+
],
|
| 35 |
+
"output": 2
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"input": [
|
| 39 |
+
618175,
|
| 40 |
+
609876,
|
| 41 |
+
581435
|
| 42 |
+
],
|
| 43 |
+
"output": 3
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"input": [
|
| 47 |
+
361954,
|
| 48 |
+
240150,
|
| 49 |
+
612661
|
| 50 |
+
],
|
| 51 |
+
"output": 2
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"input": [
|
| 55 |
+
83875,
|
| 56 |
+
968567,
|
| 57 |
+
762526
|
| 58 |
+
],
|
| 59 |
+
"output": 1
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
580653,
|
| 64 |
+
474757,
|
| 65 |
+
204541
|
| 66 |
+
],
|
| 67 |
+
"output": 4
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"input": [
|
| 71 |
+
214815,
|
| 72 |
+
107733,
|
| 73 |
+
426649
|
| 74 |
+
],
|
| 75 |
+
"output": 2
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"input": [
|
| 79 |
+
358410,
|
| 80 |
+
852082,
|
| 81 |
+
390378
|
| 82 |
+
],
|
| 83 |
+
"output": 1
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"input": [
|
| 87 |
+
200117,
|
| 88 |
+
650561,
|
| 89 |
+
233174
|
| 90 |
+
],
|
| 91 |
+
"output": 1
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"input": [
|
| 95 |
+
563273,
|
| 96 |
+
879850,
|
| 97 |
+
328505
|
| 98 |
+
],
|
| 99 |
+
"output": 2
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
"haskell_template": "waysToBuyPensPencils :: Int -> Int -> Int -> Int\nwaysToBuyPensPencils total cost1 cost2 ",
|
| 103 |
+
"ocaml_template": "let waysToBuyPensPencils (total: int) (cost1: int) (cost2: int) : int = ",
|
| 104 |
+
"scala_template": "def waysToBuyPensPencils(total: Int,cost1: Int,cost2: Int): Int = { \n \n}",
|
| 105 |
+
"java_template": "public static int waysToBuyPensPencils(int total, int cost1, int cost2) {\n\n}",
|
| 106 |
+
"python_template": "class Solution(object):\n def waysToBuyPensPencils(self, total, cost1, cost2):\n \"\"\"\n :type total: int\n :type cost1: int\n :type cost2: int\n :rtype: int\n \"\"\"\n "
|
| 107 |
+
}
|
number_of_ways_to_buy_pens_and_pencils/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 9 (waysToBuyPensPencils 20 10 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (waysToBuyPensPencils 5 10 10)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for waysToBuyPensPencils" >::: [
|
| 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_ways_to_buy_pens_and_pencils/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.waysToBuyPensPencils(20,10,5), 9)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.waysToBuyPensPencils(5,10,10), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_ways_to_divide_a_long_corridor/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_ways_to_divide_a_long_corridor/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 (numberOfWays \"SSPPSPS \")," 3 (numberOfWays "SSPPSPS"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numberOfWays \"PPSPSP \")," 1 (numberOfWays "PPSPSP"))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (numberOfWays \"S \")," 0 (numberOfWays "S"))
|
| 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_ways_to_divide_a_long_corridor/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(3, numberOfWays("SSPPSPS"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, numberOfWays("PPSPSP"));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, numberOfWays("S"));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
number_of_ways_to_divide_a_long_corridor/meta.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2251,
|
| 3 |
+
"name": "number_of_ways_to_divide_a_long_corridor",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor/",
|
| 6 |
+
"date": "1641600000000",
|
| 7 |
+
"task_description": "Along a long library corridor, there is a line of seats and decorative plants. You are given a **0-indexed** string `corridor` of length `n` consisting of letters `'S'` and `'P'` where each `'S'` represents a seat and each `'P'` represents a plant. One room divider has **already** been installed to the left of index `0`, and **another** to the right of index `n - 1`. Additional room dividers can be installed. For each position between indices `i - 1` and `i` (`1 <= i <= n - 1`), at most one divider can be installed. Divide the corridor into non-overlapping sections, where each section has **exactly two seats** with any number of plants. There may be multiple ways to perform the division. Two ways are **different** if there is a position with a room divider installed in the first way but not in the second way. Return _the number of ways to divide the corridor_. Since the answer may be very large, return it **modulo** `109 + 7`. If there is no way, return `0`. **Example 1:** ``` **Input:** corridor = \"SSPPSPS\" **Output:** 3 **Explanation:** There are 3 different ways to divide the corridor. The black bars in the above image indicate the two room dividers already installed. Note that in each of the ways, **each** section has exactly **two** seats. ``` **Example 2:** ``` **Input:** corridor = \"PPSPSP\" **Output:** 1 **Explanation:** There is only 1 way to divide the corridor, by not installing any additional dividers. Installing any would create some section that does not have exactly two seats. ``` **Example 3:** ``` **Input:** corridor = \"S\" **Output:** 0 **Explanation:** There is no way to divide the corridor because there will always be a section that does not have exactly two seats. ``` **Constraints:** `n == corridor.length` `1 <= n <= 105` `corridor[i]` is either `'S'` or `'P'`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "corridor = \"SSPPSPS\"",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "corridor = \"PPSPSP\"",
|
| 17 |
+
"output": "1 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "corridor = \"S\"",
|
| 22 |
+
"output": "0 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": "SSPSSSSSPSSSPSSPSSSSSPSSPSSSSSPSSPSSPPSSSSSSSPPSSSPPPSSSSPPSSSSPSSSSPSSSSSPS",
|
| 28 |
+
"output": 4608
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"input": "PPSPSPSSSSSSPPSSSSSPSPSPSPSSPPPPSPSSSSSSPSSPSSSSPSSPSSSSSSSPSSSSSSSPSSPSPSPPSPSSSSSPPSSPPS",
|
| 32 |
+
"output": 960
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": "SPSSPSPSSSSSSS",
|
| 36 |
+
"output": 0
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": "SSSSSSSSSSSSSSSSSSSSSSSPPSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSPSPSSSSSSSS",
|
| 40 |
+
"output": 0
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": "PPSPPPSSSSPPPPPPPPPPSSPSSPPPSPPPPSPPSSPSPPPPPPPPPPPPPPPPPPPPPPPPPPP",
|
| 44 |
+
"output": 5
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"input": "PPPPPPPSPPPPPSPPSSSSPPPPPPPSSSPPSSSPSPSSPPSPSPPP",
|
| 48 |
+
"output": 0
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"input": "SSSSSSPSSPSSSSSSSSSSSSSS",
|
| 52 |
+
"output": 4
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": "PSSPPSPPSSSPSS",
|
| 56 |
+
"output": 6
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": "PPPPPSPPPPPPPPPPPPPPPSPSSSSPPPPP",
|
| 60 |
+
"output": 2
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"input": "SSSSSSSSSSSPSSSSSSSSSSSSS",
|
| 64 |
+
"output": 1
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"haskell_template": "numberOfWays :: String -> Int\nnumberOfWays corridor ",
|
| 68 |
+
"ocaml_template": "let numberOfWays (corridor: string) : int = ",
|
| 69 |
+
"scala_template": "def numberOfWays(corridor: String): Int = { \n \n}",
|
| 70 |
+
"java_template": "public static int numberOfWays(String corridor) {\n\n}",
|
| 71 |
+
"python_template": "class Solution(object):\n def numberOfWays(self, corridor):\n \"\"\"\n :type corridor: str\n :rtype: int\n \"\"\"\n "
|
| 72 |
+
}
|
number_of_ways_to_divide_a_long_corridor/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 3 (numberOfWays "SSPPSPS")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (numberOfWays "PPSPSP")
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 0 (numberOfWays "S")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for numberOfWays" >::: [
|
| 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_ways_to_divide_a_long_corridor/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numberOfWays("SSPPSPS"), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numberOfWays("PPSPSP"), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.numberOfWays("S"), 0)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
number_of_ways_to_earn_points/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_ways_to_earn_points/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 (waysToReachTarget 6 [[6,1],[3,2],[2,3]])," 7 (waysToReachTarget 6 [[6,1],[3,2],[2,3]]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (waysToReachTarget 5 [[50,1],[50,2],[50,5]])," 4 (waysToReachTarget 5 [[50,1],[50,2],[50,5]]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (waysToReachTarget 18 [[6,1],[3,2],[2,3]])," 1 (waysToReachTarget 18 [[6,1],[3,2],[2,3]]))
|
| 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_ways_to_earn_points/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(7, waysToReachTarget(6, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(6,1)),new ArrayList<>(Arrays.asList(3,2)),new ArrayList<>(Arrays.asList(2,3))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(4, waysToReachTarget(5, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(50,1)),new ArrayList<>(Arrays.asList(50,2)),new ArrayList<>(Arrays.asList(50,5))))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(1, waysToReachTarget(18, new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(6,1)),new ArrayList<>(Arrays.asList(3,2)),new ArrayList<>(Arrays.asList(2,3))))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
number_of_ways_to_earn_points/meta.json
ADDED
|
@@ -0,0 +1,1300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2648,
|
| 3 |
+
"name": "number_of_ways_to_earn_points",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-ways-to-earn-points/",
|
| 6 |
+
"date": "1677369600000",
|
| 7 |
+
"task_description": "There is a test that has `n` types of questions. You are given an integer `target` and a **0-indexed** 2D integer array `types` where `types[i] = [counti, marksi]` indicates that there are `counti` questions of the `ith` type, and each one of them is worth `marksi` points. Return _the number of ways you can earn **exactly** _`target`_ points in the exam_. Since the answer may be too large, return it **modulo** `109 + 7`. **Note** that questions of the same type are indistinguishable. For example, if there are `3` questions of the same type, then solving the `1st` and `2nd` questions is the same as solving the `1st` and `3rd` questions, or the `2nd` and `3rd` questions. **Example 1:** ``` **Input:** target = 6, types = [[6,1],[3,2],[2,3]] **Output:** 7 **Explanation:** You can earn 6 points in one of the seven ways: - Solve 6 questions of the 0th type: 1 + 1 + 1 + 1 + 1 + 1 = 6 - Solve 4 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 1 + 2 = 6 - Solve 2 questions of the 0th type and 2 questions of the 1st type: 1 + 1 + 2 + 2 = 6 - Solve 3 questions of the 0th type and 1 question of the 2nd type: 1 + 1 + 1 + 3 = 6 - Solve 1 question of the 0th type, 1 question of the 1st type and 1 question of the 2nd type: 1 + 2 + 3 = 6 - Solve 3 questions of the 1st type: 2 + 2 + 2 = 6 - Solve 2 questions of the 2nd type: 3 + 3 = 6 ``` **Example 2:** ``` **Input:** target = 5, types = [[50,1],[50,2],[50,5]] **Output:** 4 **Explanation:** You can earn 5 points in one of the four ways: - Solve 5 questions of the 0th type: 1 + 1 + 1 + 1 + 1 = 5 - Solve 3 questions of the 0th type and 1 question of the 1st type: 1 + 1 + 1 + 2 = 5 - Solve 1 questions of the 0th type and 2 questions of the 1st type: 1 + 2 + 2 = 5 - Solve 1 question of the 2nd type: 5 ``` **Example 3:** ``` **Input:** target = 18, types = [[6,1],[3,2],[2,3]] **Output:** 1 **Explanation:** You can only earn 18 points by answering all questions. ``` **Constraints:** `1 <= target <= 1000` `n == types.length` `1 <= n <= 50` `types[i].length == 2` `1 <= counti, marksi <= 50`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "target = 6, types = [[6,1],[3,2],[2,3]]",
|
| 12 |
+
"output": "7 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "target = 5, types = [[50,1],[50,2],[50,5]]",
|
| 17 |
+
"output": "4 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "target = 18, types = [[6,1],[3,2],[2,3]]",
|
| 22 |
+
"output": "1 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
862,
|
| 29 |
+
[
|
| 30 |
+
[
|
| 31 |
+
9,
|
| 32 |
+
7
|
| 33 |
+
],
|
| 34 |
+
[
|
| 35 |
+
2,
|
| 36 |
+
36
|
| 37 |
+
],
|
| 38 |
+
[
|
| 39 |
+
32,
|
| 40 |
+
8
|
| 41 |
+
],
|
| 42 |
+
[
|
| 43 |
+
5,
|
| 44 |
+
37
|
| 45 |
+
],
|
| 46 |
+
[
|
| 47 |
+
6,
|
| 48 |
+
35
|
| 49 |
+
],
|
| 50 |
+
[
|
| 51 |
+
30,
|
| 52 |
+
2
|
| 53 |
+
],
|
| 54 |
+
[
|
| 55 |
+
23,
|
| 56 |
+
18
|
| 57 |
+
],
|
| 58 |
+
[
|
| 59 |
+
48,
|
| 60 |
+
47
|
| 61 |
+
],
|
| 62 |
+
[
|
| 63 |
+
33,
|
| 64 |
+
30
|
| 65 |
+
],
|
| 66 |
+
[
|
| 67 |
+
6,
|
| 68 |
+
24
|
| 69 |
+
],
|
| 70 |
+
[
|
| 71 |
+
39,
|
| 72 |
+
20
|
| 73 |
+
],
|
| 74 |
+
[
|
| 75 |
+
33,
|
| 76 |
+
40
|
| 77 |
+
],
|
| 78 |
+
[
|
| 79 |
+
40,
|
| 80 |
+
18
|
| 81 |
+
],
|
| 82 |
+
[
|
| 83 |
+
49,
|
| 84 |
+
33
|
| 85 |
+
],
|
| 86 |
+
[
|
| 87 |
+
16,
|
| 88 |
+
3
|
| 89 |
+
],
|
| 90 |
+
[
|
| 91 |
+
32,
|
| 92 |
+
22
|
| 93 |
+
],
|
| 94 |
+
[
|
| 95 |
+
2,
|
| 96 |
+
22
|
| 97 |
+
],
|
| 98 |
+
[
|
| 99 |
+
11,
|
| 100 |
+
48
|
| 101 |
+
],
|
| 102 |
+
[
|
| 103 |
+
16,
|
| 104 |
+
47
|
| 105 |
+
],
|
| 106 |
+
[
|
| 107 |
+
27,
|
| 108 |
+
9
|
| 109 |
+
],
|
| 110 |
+
[
|
| 111 |
+
44,
|
| 112 |
+
48
|
| 113 |
+
],
|
| 114 |
+
[
|
| 115 |
+
18,
|
| 116 |
+
29
|
| 117 |
+
],
|
| 118 |
+
[
|
| 119 |
+
7,
|
| 120 |
+
2
|
| 121 |
+
],
|
| 122 |
+
[
|
| 123 |
+
33,
|
| 124 |
+
16
|
| 125 |
+
],
|
| 126 |
+
[
|
| 127 |
+
40,
|
| 128 |
+
1
|
| 129 |
+
],
|
| 130 |
+
[
|
| 131 |
+
19,
|
| 132 |
+
47
|
| 133 |
+
],
|
| 134 |
+
[
|
| 135 |
+
34,
|
| 136 |
+
33
|
| 137 |
+
],
|
| 138 |
+
[
|
| 139 |
+
26,
|
| 140 |
+
8
|
| 141 |
+
],
|
| 142 |
+
[
|
| 143 |
+
39,
|
| 144 |
+
11
|
| 145 |
+
],
|
| 146 |
+
[
|
| 147 |
+
37,
|
| 148 |
+
25
|
| 149 |
+
],
|
| 150 |
+
[
|
| 151 |
+
26,
|
| 152 |
+
39
|
| 153 |
+
],
|
| 154 |
+
[
|
| 155 |
+
38,
|
| 156 |
+
15
|
| 157 |
+
],
|
| 158 |
+
[
|
| 159 |
+
13,
|
| 160 |
+
49
|
| 161 |
+
],
|
| 162 |
+
[
|
| 163 |
+
48,
|
| 164 |
+
18
|
| 165 |
+
],
|
| 166 |
+
[
|
| 167 |
+
17,
|
| 168 |
+
37
|
| 169 |
+
],
|
| 170 |
+
[
|
| 171 |
+
43,
|
| 172 |
+
1
|
| 173 |
+
],
|
| 174 |
+
[
|
| 175 |
+
44,
|
| 176 |
+
36
|
| 177 |
+
],
|
| 178 |
+
[
|
| 179 |
+
23,
|
| 180 |
+
33
|
| 181 |
+
]
|
| 182 |
+
]
|
| 183 |
+
],
|
| 184 |
+
"output": 544536689
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"input": [
|
| 188 |
+
971,
|
| 189 |
+
[
|
| 190 |
+
[
|
| 191 |
+
44,
|
| 192 |
+
8
|
| 193 |
+
],
|
| 194 |
+
[
|
| 195 |
+
14,
|
| 196 |
+
40
|
| 197 |
+
],
|
| 198 |
+
[
|
| 199 |
+
30,
|
| 200 |
+
1
|
| 201 |
+
],
|
| 202 |
+
[
|
| 203 |
+
11,
|
| 204 |
+
12
|
| 205 |
+
],
|
| 206 |
+
[
|
| 207 |
+
26,
|
| 208 |
+
3
|
| 209 |
+
],
|
| 210 |
+
[
|
| 211 |
+
31,
|
| 212 |
+
7
|
| 213 |
+
],
|
| 214 |
+
[
|
| 215 |
+
39,
|
| 216 |
+
3
|
| 217 |
+
],
|
| 218 |
+
[
|
| 219 |
+
26,
|
| 220 |
+
44
|
| 221 |
+
],
|
| 222 |
+
[
|
| 223 |
+
46,
|
| 224 |
+
24
|
| 225 |
+
],
|
| 226 |
+
[
|
| 227 |
+
17,
|
| 228 |
+
7
|
| 229 |
+
],
|
| 230 |
+
[
|
| 231 |
+
12,
|
| 232 |
+
25
|
| 233 |
+
],
|
| 234 |
+
[
|
| 235 |
+
15,
|
| 236 |
+
22
|
| 237 |
+
],
|
| 238 |
+
[
|
| 239 |
+
39,
|
| 240 |
+
18
|
| 241 |
+
],
|
| 242 |
+
[
|
| 243 |
+
4,
|
| 244 |
+
11
|
| 245 |
+
],
|
| 246 |
+
[
|
| 247 |
+
12,
|
| 248 |
+
40
|
| 249 |
+
]
|
| 250 |
+
]
|
| 251 |
+
],
|
| 252 |
+
"output": 670104762
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"input": [
|
| 256 |
+
891,
|
| 257 |
+
[
|
| 258 |
+
[
|
| 259 |
+
47,
|
| 260 |
+
18
|
| 261 |
+
],
|
| 262 |
+
[
|
| 263 |
+
19,
|
| 264 |
+
9
|
| 265 |
+
],
|
| 266 |
+
[
|
| 267 |
+
25,
|
| 268 |
+
34
|
| 269 |
+
],
|
| 270 |
+
[
|
| 271 |
+
37,
|
| 272 |
+
34
|
| 273 |
+
],
|
| 274 |
+
[
|
| 275 |
+
4,
|
| 276 |
+
38
|
| 277 |
+
],
|
| 278 |
+
[
|
| 279 |
+
42,
|
| 280 |
+
45
|
| 281 |
+
],
|
| 282 |
+
[
|
| 283 |
+
7,
|
| 284 |
+
43
|
| 285 |
+
],
|
| 286 |
+
[
|
| 287 |
+
14,
|
| 288 |
+
34
|
| 289 |
+
],
|
| 290 |
+
[
|
| 291 |
+
13,
|
| 292 |
+
22
|
| 293 |
+
],
|
| 294 |
+
[
|
| 295 |
+
21,
|
| 296 |
+
50
|
| 297 |
+
],
|
| 298 |
+
[
|
| 299 |
+
3,
|
| 300 |
+
2
|
| 301 |
+
],
|
| 302 |
+
[
|
| 303 |
+
12,
|
| 304 |
+
30
|
| 305 |
+
],
|
| 306 |
+
[
|
| 307 |
+
13,
|
| 308 |
+
27
|
| 309 |
+
],
|
| 310 |
+
[
|
| 311 |
+
8,
|
| 312 |
+
1
|
| 313 |
+
],
|
| 314 |
+
[
|
| 315 |
+
47,
|
| 316 |
+
34
|
| 317 |
+
],
|
| 318 |
+
[
|
| 319 |
+
20,
|
| 320 |
+
49
|
| 321 |
+
],
|
| 322 |
+
[
|
| 323 |
+
37,
|
| 324 |
+
3
|
| 325 |
+
],
|
| 326 |
+
[
|
| 327 |
+
6,
|
| 328 |
+
30
|
| 329 |
+
],
|
| 330 |
+
[
|
| 331 |
+
27,
|
| 332 |
+
32
|
| 333 |
+
],
|
| 334 |
+
[
|
| 335 |
+
38,
|
| 336 |
+
21
|
| 337 |
+
],
|
| 338 |
+
[
|
| 339 |
+
36,
|
| 340 |
+
42
|
| 341 |
+
],
|
| 342 |
+
[
|
| 343 |
+
43,
|
| 344 |
+
27
|
| 345 |
+
],
|
| 346 |
+
[
|
| 347 |
+
46,
|
| 348 |
+
35
|
| 349 |
+
],
|
| 350 |
+
[
|
| 351 |
+
8,
|
| 352 |
+
18
|
| 353 |
+
],
|
| 354 |
+
[
|
| 355 |
+
35,
|
| 356 |
+
48
|
| 357 |
+
],
|
| 358 |
+
[
|
| 359 |
+
4,
|
| 360 |
+
21
|
| 361 |
+
],
|
| 362 |
+
[
|
| 363 |
+
16,
|
| 364 |
+
50
|
| 365 |
+
],
|
| 366 |
+
[
|
| 367 |
+
42,
|
| 368 |
+
23
|
| 369 |
+
],
|
| 370 |
+
[
|
| 371 |
+
26,
|
| 372 |
+
39
|
| 373 |
+
],
|
| 374 |
+
[
|
| 375 |
+
40,
|
| 376 |
+
22
|
| 377 |
+
],
|
| 378 |
+
[
|
| 379 |
+
46,
|
| 380 |
+
39
|
| 381 |
+
],
|
| 382 |
+
[
|
| 383 |
+
14,
|
| 384 |
+
24
|
| 385 |
+
],
|
| 386 |
+
[
|
| 387 |
+
24,
|
| 388 |
+
37
|
| 389 |
+
],
|
| 390 |
+
[
|
| 391 |
+
12,
|
| 392 |
+
29
|
| 393 |
+
],
|
| 394 |
+
[
|
| 395 |
+
48,
|
| 396 |
+
45
|
| 397 |
+
],
|
| 398 |
+
[
|
| 399 |
+
13,
|
| 400 |
+
28
|
| 401 |
+
],
|
| 402 |
+
[
|
| 403 |
+
39,
|
| 404 |
+
47
|
| 405 |
+
],
|
| 406 |
+
[
|
| 407 |
+
41,
|
| 408 |
+
36
|
| 409 |
+
]
|
| 410 |
+
]
|
| 411 |
+
],
|
| 412 |
+
"output": 605233870
|
| 413 |
+
},
|
| 414 |
+
{
|
| 415 |
+
"input": [
|
| 416 |
+
194,
|
| 417 |
+
[
|
| 418 |
+
[
|
| 419 |
+
8,
|
| 420 |
+
48
|
| 421 |
+
],
|
| 422 |
+
[
|
| 423 |
+
23,
|
| 424 |
+
4
|
| 425 |
+
],
|
| 426 |
+
[
|
| 427 |
+
48,
|
| 428 |
+
7
|
| 429 |
+
],
|
| 430 |
+
[
|
| 431 |
+
28,
|
| 432 |
+
5
|
| 433 |
+
],
|
| 434 |
+
[
|
| 435 |
+
44,
|
| 436 |
+
17
|
| 437 |
+
],
|
| 438 |
+
[
|
| 439 |
+
4,
|
| 440 |
+
27
|
| 441 |
+
],
|
| 442 |
+
[
|
| 443 |
+
14,
|
| 444 |
+
18
|
| 445 |
+
],
|
| 446 |
+
[
|
| 447 |
+
40,
|
| 448 |
+
36
|
| 449 |
+
],
|
| 450 |
+
[
|
| 451 |
+
10,
|
| 452 |
+
8
|
| 453 |
+
],
|
| 454 |
+
[
|
| 455 |
+
17,
|
| 456 |
+
31
|
| 457 |
+
],
|
| 458 |
+
[
|
| 459 |
+
16,
|
| 460 |
+
33
|
| 461 |
+
],
|
| 462 |
+
[
|
| 463 |
+
7,
|
| 464 |
+
29
|
| 465 |
+
],
|
| 466 |
+
[
|
| 467 |
+
15,
|
| 468 |
+
49
|
| 469 |
+
],
|
| 470 |
+
[
|
| 471 |
+
49,
|
| 472 |
+
45
|
| 473 |
+
],
|
| 474 |
+
[
|
| 475 |
+
24,
|
| 476 |
+
22
|
| 477 |
+
],
|
| 478 |
+
[
|
| 479 |
+
33,
|
| 480 |
+
49
|
| 481 |
+
],
|
| 482 |
+
[
|
| 483 |
+
6,
|
| 484 |
+
2
|
| 485 |
+
],
|
| 486 |
+
[
|
| 487 |
+
35,
|
| 488 |
+
26
|
| 489 |
+
],
|
| 490 |
+
[
|
| 491 |
+
7,
|
| 492 |
+
2
|
| 493 |
+
],
|
| 494 |
+
[
|
| 495 |
+
45,
|
| 496 |
+
23
|
| 497 |
+
],
|
| 498 |
+
[
|
| 499 |
+
27,
|
| 500 |
+
46
|
| 501 |
+
],
|
| 502 |
+
[
|
| 503 |
+
48,
|
| 504 |
+
20
|
| 505 |
+
],
|
| 506 |
+
[
|
| 507 |
+
14,
|
| 508 |
+
28
|
| 509 |
+
],
|
| 510 |
+
[
|
| 511 |
+
30,
|
| 512 |
+
5
|
| 513 |
+
],
|
| 514 |
+
[
|
| 515 |
+
42,
|
| 516 |
+
18
|
| 517 |
+
],
|
| 518 |
+
[
|
| 519 |
+
50,
|
| 520 |
+
32
|
| 521 |
+
],
|
| 522 |
+
[
|
| 523 |
+
14,
|
| 524 |
+
1
|
| 525 |
+
],
|
| 526 |
+
[
|
| 527 |
+
7,
|
| 528 |
+
43
|
| 529 |
+
],
|
| 530 |
+
[
|
| 531 |
+
6,
|
| 532 |
+
8
|
| 533 |
+
],
|
| 534 |
+
[
|
| 535 |
+
45,
|
| 536 |
+
13
|
| 537 |
+
],
|
| 538 |
+
[
|
| 539 |
+
47,
|
| 540 |
+
2
|
| 541 |
+
],
|
| 542 |
+
[
|
| 543 |
+
34,
|
| 544 |
+
12
|
| 545 |
+
],
|
| 546 |
+
[
|
| 547 |
+
22,
|
| 548 |
+
2
|
| 549 |
+
],
|
| 550 |
+
[
|
| 551 |
+
1,
|
| 552 |
+
49
|
| 553 |
+
],
|
| 554 |
+
[
|
| 555 |
+
40,
|
| 556 |
+
9
|
| 557 |
+
],
|
| 558 |
+
[
|
| 559 |
+
9,
|
| 560 |
+
5
|
| 561 |
+
]
|
| 562 |
+
]
|
| 563 |
+
],
|
| 564 |
+
"output": 163333403
|
| 565 |
+
},
|
| 566 |
+
{
|
| 567 |
+
"input": [
|
| 568 |
+
593,
|
| 569 |
+
[
|
| 570 |
+
[
|
| 571 |
+
28,
|
| 572 |
+
27
|
| 573 |
+
],
|
| 574 |
+
[
|
| 575 |
+
32,
|
| 576 |
+
42
|
| 577 |
+
],
|
| 578 |
+
[
|
| 579 |
+
16,
|
| 580 |
+
34
|
| 581 |
+
],
|
| 582 |
+
[
|
| 583 |
+
9,
|
| 584 |
+
30
|
| 585 |
+
],
|
| 586 |
+
[
|
| 587 |
+
14,
|
| 588 |
+
16
|
| 589 |
+
],
|
| 590 |
+
[
|
| 591 |
+
33,
|
| 592 |
+
49
|
| 593 |
+
],
|
| 594 |
+
[
|
| 595 |
+
6,
|
| 596 |
+
47
|
| 597 |
+
],
|
| 598 |
+
[
|
| 599 |
+
11,
|
| 600 |
+
21
|
| 601 |
+
],
|
| 602 |
+
[
|
| 603 |
+
14,
|
| 604 |
+
31
|
| 605 |
+
],
|
| 606 |
+
[
|
| 607 |
+
18,
|
| 608 |
+
33
|
| 609 |
+
],
|
| 610 |
+
[
|
| 611 |
+
26,
|
| 612 |
+
25
|
| 613 |
+
],
|
| 614 |
+
[
|
| 615 |
+
29,
|
| 616 |
+
47
|
| 617 |
+
],
|
| 618 |
+
[
|
| 619 |
+
40,
|
| 620 |
+
41
|
| 621 |
+
],
|
| 622 |
+
[
|
| 623 |
+
17,
|
| 624 |
+
31
|
| 625 |
+
],
|
| 626 |
+
[
|
| 627 |
+
7,
|
| 628 |
+
10
|
| 629 |
+
],
|
| 630 |
+
[
|
| 631 |
+
6,
|
| 632 |
+
1
|
| 633 |
+
],
|
| 634 |
+
[
|
| 635 |
+
3,
|
| 636 |
+
3
|
| 637 |
+
],
|
| 638 |
+
[
|
| 639 |
+
2,
|
| 640 |
+
23
|
| 641 |
+
],
|
| 642 |
+
[
|
| 643 |
+
34,
|
| 644 |
+
26
|
| 645 |
+
],
|
| 646 |
+
[
|
| 647 |
+
8,
|
| 648 |
+
39
|
| 649 |
+
],
|
| 650 |
+
[
|
| 651 |
+
2,
|
| 652 |
+
48
|
| 653 |
+
],
|
| 654 |
+
[
|
| 655 |
+
37,
|
| 656 |
+
39
|
| 657 |
+
],
|
| 658 |
+
[
|
| 659 |
+
35,
|
| 660 |
+
42
|
| 661 |
+
],
|
| 662 |
+
[
|
| 663 |
+
45,
|
| 664 |
+
11
|
| 665 |
+
],
|
| 666 |
+
[
|
| 667 |
+
16,
|
| 668 |
+
24
|
| 669 |
+
],
|
| 670 |
+
[
|
| 671 |
+
19,
|
| 672 |
+
6
|
| 673 |
+
],
|
| 674 |
+
[
|
| 675 |
+
17,
|
| 676 |
+
4
|
| 677 |
+
],
|
| 678 |
+
[
|
| 679 |
+
12,
|
| 680 |
+
3
|
| 681 |
+
]
|
| 682 |
+
]
|
| 683 |
+
],
|
| 684 |
+
"output": 168221700
|
| 685 |
+
},
|
| 686 |
+
{
|
| 687 |
+
"input": [
|
| 688 |
+
506,
|
| 689 |
+
[
|
| 690 |
+
[
|
| 691 |
+
39,
|
| 692 |
+
49
|
| 693 |
+
],
|
| 694 |
+
[
|
| 695 |
+
16,
|
| 696 |
+
47
|
| 697 |
+
],
|
| 698 |
+
[
|
| 699 |
+
17,
|
| 700 |
+
36
|
| 701 |
+
],
|
| 702 |
+
[
|
| 703 |
+
44,
|
| 704 |
+
33
|
| 705 |
+
],
|
| 706 |
+
[
|
| 707 |
+
43,
|
| 708 |
+
22
|
| 709 |
+
],
|
| 710 |
+
[
|
| 711 |
+
37,
|
| 712 |
+
17
|
| 713 |
+
],
|
| 714 |
+
[
|
| 715 |
+
20,
|
| 716 |
+
20
|
| 717 |
+
],
|
| 718 |
+
[
|
| 719 |
+
19,
|
| 720 |
+
44
|
| 721 |
+
],
|
| 722 |
+
[
|
| 723 |
+
45,
|
| 724 |
+
32
|
| 725 |
+
],
|
| 726 |
+
[
|
| 727 |
+
16,
|
| 728 |
+
29
|
| 729 |
+
],
|
| 730 |
+
[
|
| 731 |
+
24,
|
| 732 |
+
27
|
| 733 |
+
],
|
| 734 |
+
[
|
| 735 |
+
42,
|
| 736 |
+
29
|
| 737 |
+
],
|
| 738 |
+
[
|
| 739 |
+
10,
|
| 740 |
+
40
|
| 741 |
+
],
|
| 742 |
+
[
|
| 743 |
+
27,
|
| 744 |
+
12
|
| 745 |
+
],
|
| 746 |
+
[
|
| 747 |
+
16,
|
| 748 |
+
19
|
| 749 |
+
],
|
| 750 |
+
[
|
| 751 |
+
43,
|
| 752 |
+
26
|
| 753 |
+
],
|
| 754 |
+
[
|
| 755 |
+
1,
|
| 756 |
+
31
|
| 757 |
+
],
|
| 758 |
+
[
|
| 759 |
+
11,
|
| 760 |
+
29
|
| 761 |
+
],
|
| 762 |
+
[
|
| 763 |
+
22,
|
| 764 |
+
20
|
| 765 |
+
],
|
| 766 |
+
[
|
| 767 |
+
14,
|
| 768 |
+
31
|
| 769 |
+
],
|
| 770 |
+
[
|
| 771 |
+
11,
|
| 772 |
+
26
|
| 773 |
+
],
|
| 774 |
+
[
|
| 775 |
+
11,
|
| 776 |
+
24
|
| 777 |
+
]
|
| 778 |
+
]
|
| 779 |
+
],
|
| 780 |
+
"output": 216374332
|
| 781 |
+
},
|
| 782 |
+
{
|
| 783 |
+
"input": [
|
| 784 |
+
683,
|
| 785 |
+
[
|
| 786 |
+
[
|
| 787 |
+
37,
|
| 788 |
+
23
|
| 789 |
+
],
|
| 790 |
+
[
|
| 791 |
+
2,
|
| 792 |
+
3
|
| 793 |
+
],
|
| 794 |
+
[
|
| 795 |
+
8,
|
| 796 |
+
44
|
| 797 |
+
],
|
| 798 |
+
[
|
| 799 |
+
26,
|
| 800 |
+
48
|
| 801 |
+
],
|
| 802 |
+
[
|
| 803 |
+
17,
|
| 804 |
+
2
|
| 805 |
+
],
|
| 806 |
+
[
|
| 807 |
+
13,
|
| 808 |
+
36
|
| 809 |
+
],
|
| 810 |
+
[
|
| 811 |
+
26,
|
| 812 |
+
16
|
| 813 |
+
],
|
| 814 |
+
[
|
| 815 |
+
10,
|
| 816 |
+
23
|
| 817 |
+
],
|
| 818 |
+
[
|
| 819 |
+
46,
|
| 820 |
+
9
|
| 821 |
+
],
|
| 822 |
+
[
|
| 823 |
+
10,
|
| 824 |
+
37
|
| 825 |
+
],
|
| 826 |
+
[
|
| 827 |
+
30,
|
| 828 |
+
23
|
| 829 |
+
],
|
| 830 |
+
[
|
| 831 |
+
16,
|
| 832 |
+
50
|
| 833 |
+
],
|
| 834 |
+
[
|
| 835 |
+
18,
|
| 836 |
+
38
|
| 837 |
+
],
|
| 838 |
+
[
|
| 839 |
+
49,
|
| 840 |
+
28
|
| 841 |
+
],
|
| 842 |
+
[
|
| 843 |
+
6,
|
| 844 |
+
50
|
| 845 |
+
],
|
| 846 |
+
[
|
| 847 |
+
4,
|
| 848 |
+
43
|
| 849 |
+
],
|
| 850 |
+
[
|
| 851 |
+
40,
|
| 852 |
+
31
|
| 853 |
+
],
|
| 854 |
+
[
|
| 855 |
+
36,
|
| 856 |
+
20
|
| 857 |
+
],
|
| 858 |
+
[
|
| 859 |
+
3,
|
| 860 |
+
15
|
| 861 |
+
],
|
| 862 |
+
[
|
| 863 |
+
46,
|
| 864 |
+
29
|
| 865 |
+
],
|
| 866 |
+
[
|
| 867 |
+
48,
|
| 868 |
+
14
|
| 869 |
+
],
|
| 870 |
+
[
|
| 871 |
+
25,
|
| 872 |
+
29
|
| 873 |
+
],
|
| 874 |
+
[
|
| 875 |
+
31,
|
| 876 |
+
33
|
| 877 |
+
],
|
| 878 |
+
[
|
| 879 |
+
25,
|
| 880 |
+
24
|
| 881 |
+
],
|
| 882 |
+
[
|
| 883 |
+
10,
|
| 884 |
+
26
|
| 885 |
+
],
|
| 886 |
+
[
|
| 887 |
+
9,
|
| 888 |
+
29
|
| 889 |
+
],
|
| 890 |
+
[
|
| 891 |
+
13,
|
| 892 |
+
12
|
| 893 |
+
],
|
| 894 |
+
[
|
| 895 |
+
22,
|
| 896 |
+
13
|
| 897 |
+
],
|
| 898 |
+
[
|
| 899 |
+
21,
|
| 900 |
+
26
|
| 901 |
+
],
|
| 902 |
+
[
|
| 903 |
+
30,
|
| 904 |
+
24
|
| 905 |
+
],
|
| 906 |
+
[
|
| 907 |
+
39,
|
| 908 |
+
38
|
| 909 |
+
],
|
| 910 |
+
[
|
| 911 |
+
5,
|
| 912 |
+
28
|
| 913 |
+
],
|
| 914 |
+
[
|
| 915 |
+
30,
|
| 916 |
+
16
|
| 917 |
+
],
|
| 918 |
+
[
|
| 919 |
+
9,
|
| 920 |
+
4
|
| 921 |
+
],
|
| 922 |
+
[
|
| 923 |
+
11,
|
| 924 |
+
14
|
| 925 |
+
],
|
| 926 |
+
[
|
| 927 |
+
18,
|
| 928 |
+
37
|
| 929 |
+
],
|
| 930 |
+
[
|
| 931 |
+
5,
|
| 932 |
+
43
|
| 933 |
+
],
|
| 934 |
+
[
|
| 935 |
+
17,
|
| 936 |
+
30
|
| 937 |
+
],
|
| 938 |
+
[
|
| 939 |
+
18,
|
| 940 |
+
39
|
| 941 |
+
],
|
| 942 |
+
[
|
| 943 |
+
26,
|
| 944 |
+
43
|
| 945 |
+
],
|
| 946 |
+
[
|
| 947 |
+
46,
|
| 948 |
+
29
|
| 949 |
+
],
|
| 950 |
+
[
|
| 951 |
+
9,
|
| 952 |
+
44
|
| 953 |
+
]
|
| 954 |
+
]
|
| 955 |
+
],
|
| 956 |
+
"output": 733333952
|
| 957 |
+
},
|
| 958 |
+
{
|
| 959 |
+
"input": [
|
| 960 |
+
84,
|
| 961 |
+
[
|
| 962 |
+
[
|
| 963 |
+
42,
|
| 964 |
+
12
|
| 965 |
+
],
|
| 966 |
+
[
|
| 967 |
+
9,
|
| 968 |
+
40
|
| 969 |
+
],
|
| 970 |
+
[
|
| 971 |
+
30,
|
| 972 |
+
48
|
| 973 |
+
],
|
| 974 |
+
[
|
| 975 |
+
13,
|
| 976 |
+
9
|
| 977 |
+
],
|
| 978 |
+
[
|
| 979 |
+
42,
|
| 980 |
+
40
|
| 981 |
+
],
|
| 982 |
+
[
|
| 983 |
+
19,
|
| 984 |
+
2
|
| 985 |
+
],
|
| 986 |
+
[
|
| 987 |
+
21,
|
| 988 |
+
42
|
| 989 |
+
],
|
| 990 |
+
[
|
| 991 |
+
44,
|
| 992 |
+
10
|
| 993 |
+
],
|
| 994 |
+
[
|
| 995 |
+
25,
|
| 996 |
+
48
|
| 997 |
+
],
|
| 998 |
+
[
|
| 999 |
+
46,
|
| 1000 |
+
38
|
| 1001 |
+
],
|
| 1002 |
+
[
|
| 1003 |
+
1,
|
| 1004 |
+
16
|
| 1005 |
+
],
|
| 1006 |
+
[
|
| 1007 |
+
40,
|
| 1008 |
+
43
|
| 1009 |
+
],
|
| 1010 |
+
[
|
| 1011 |
+
32,
|
| 1012 |
+
46
|
| 1013 |
+
],
|
| 1014 |
+
[
|
| 1015 |
+
38,
|
| 1016 |
+
11
|
| 1017 |
+
],
|
| 1018 |
+
[
|
| 1019 |
+
31,
|
| 1020 |
+
6
|
| 1021 |
+
],
|
| 1022 |
+
[
|
| 1023 |
+
2,
|
| 1024 |
+
3
|
| 1025 |
+
],
|
| 1026 |
+
[
|
| 1027 |
+
3,
|
| 1028 |
+
49
|
| 1029 |
+
],
|
| 1030 |
+
[
|
| 1031 |
+
42,
|
| 1032 |
+
36
|
| 1033 |
+
],
|
| 1034 |
+
[
|
| 1035 |
+
45,
|
| 1036 |
+
49
|
| 1037 |
+
],
|
| 1038 |
+
[
|
| 1039 |
+
20,
|
| 1040 |
+
35
|
| 1041 |
+
]
|
| 1042 |
+
]
|
| 1043 |
+
],
|
| 1044 |
+
"output": 5707
|
| 1045 |
+
},
|
| 1046 |
+
{
|
| 1047 |
+
"input": [
|
| 1048 |
+
85,
|
| 1049 |
+
[
|
| 1050 |
+
[
|
| 1051 |
+
28,
|
| 1052 |
+
19
|
| 1053 |
+
],
|
| 1054 |
+
[
|
| 1055 |
+
25,
|
| 1056 |
+
12
|
| 1057 |
+
],
|
| 1058 |
+
[
|
| 1059 |
+
7,
|
| 1060 |
+
13
|
| 1061 |
+
],
|
| 1062 |
+
[
|
| 1063 |
+
1,
|
| 1064 |
+
15
|
| 1065 |
+
],
|
| 1066 |
+
[
|
| 1067 |
+
17,
|
| 1068 |
+
2
|
| 1069 |
+
],
|
| 1070 |
+
[
|
| 1071 |
+
21,
|
| 1072 |
+
32
|
| 1073 |
+
],
|
| 1074 |
+
[
|
| 1075 |
+
42,
|
| 1076 |
+
35
|
| 1077 |
+
],
|
| 1078 |
+
[
|
| 1079 |
+
33,
|
| 1080 |
+
12
|
| 1081 |
+
],
|
| 1082 |
+
[
|
| 1083 |
+
38,
|
| 1084 |
+
7
|
| 1085 |
+
],
|
| 1086 |
+
[
|
| 1087 |
+
34,
|
| 1088 |
+
29
|
| 1089 |
+
],
|
| 1090 |
+
[
|
| 1091 |
+
25,
|
| 1092 |
+
49
|
| 1093 |
+
],
|
| 1094 |
+
[
|
| 1095 |
+
45,
|
| 1096 |
+
26
|
| 1097 |
+
],
|
| 1098 |
+
[
|
| 1099 |
+
44,
|
| 1100 |
+
21
|
| 1101 |
+
],
|
| 1102 |
+
[
|
| 1103 |
+
10,
|
| 1104 |
+
3
|
| 1105 |
+
],
|
| 1106 |
+
[
|
| 1107 |
+
7,
|
| 1108 |
+
49
|
| 1109 |
+
],
|
| 1110 |
+
[
|
| 1111 |
+
14,
|
| 1112 |
+
26
|
| 1113 |
+
],
|
| 1114 |
+
[
|
| 1115 |
+
22,
|
| 1116 |
+
25
|
| 1117 |
+
],
|
| 1118 |
+
[
|
| 1119 |
+
7,
|
| 1120 |
+
29
|
| 1121 |
+
],
|
| 1122 |
+
[
|
| 1123 |
+
44,
|
| 1124 |
+
42
|
| 1125 |
+
],
|
| 1126 |
+
[
|
| 1127 |
+
1,
|
| 1128 |
+
3
|
| 1129 |
+
],
|
| 1130 |
+
[
|
| 1131 |
+
35,
|
| 1132 |
+
29
|
| 1133 |
+
],
|
| 1134 |
+
[
|
| 1135 |
+
44,
|
| 1136 |
+
1
|
| 1137 |
+
],
|
| 1138 |
+
[
|
| 1139 |
+
33,
|
| 1140 |
+
21
|
| 1141 |
+
],
|
| 1142 |
+
[
|
| 1143 |
+
1,
|
| 1144 |
+
45
|
| 1145 |
+
],
|
| 1146 |
+
[
|
| 1147 |
+
13,
|
| 1148 |
+
37
|
| 1149 |
+
],
|
| 1150 |
+
[
|
| 1151 |
+
14,
|
| 1152 |
+
30
|
| 1153 |
+
],
|
| 1154 |
+
[
|
| 1155 |
+
47,
|
| 1156 |
+
44
|
| 1157 |
+
],
|
| 1158 |
+
[
|
| 1159 |
+
45,
|
| 1160 |
+
17
|
| 1161 |
+
],
|
| 1162 |
+
[
|
| 1163 |
+
28,
|
| 1164 |
+
33
|
| 1165 |
+
],
|
| 1166 |
+
[
|
| 1167 |
+
9,
|
| 1168 |
+
2
|
| 1169 |
+
],
|
| 1170 |
+
[
|
| 1171 |
+
11,
|
| 1172 |
+
33
|
| 1173 |
+
],
|
| 1174 |
+
[
|
| 1175 |
+
19,
|
| 1176 |
+
4
|
| 1177 |
+
],
|
| 1178 |
+
[
|
| 1179 |
+
22,
|
| 1180 |
+
46
|
| 1181 |
+
],
|
| 1182 |
+
[
|
| 1183 |
+
32,
|
| 1184 |
+
23
|
| 1185 |
+
],
|
| 1186 |
+
[
|
| 1187 |
+
25,
|
| 1188 |
+
5
|
| 1189 |
+
],
|
| 1190 |
+
[
|
| 1191 |
+
17,
|
| 1192 |
+
39
|
| 1193 |
+
],
|
| 1194 |
+
[
|
| 1195 |
+
41,
|
| 1196 |
+
19
|
| 1197 |
+
],
|
| 1198 |
+
[
|
| 1199 |
+
29,
|
| 1200 |
+
43
|
| 1201 |
+
],
|
| 1202 |
+
[
|
| 1203 |
+
22,
|
| 1204 |
+
39
|
| 1205 |
+
],
|
| 1206 |
+
[
|
| 1207 |
+
15,
|
| 1208 |
+
13
|
| 1209 |
+
],
|
| 1210 |
+
[
|
| 1211 |
+
7,
|
| 1212 |
+
33
|
| 1213 |
+
],
|
| 1214 |
+
[
|
| 1215 |
+
10,
|
| 1216 |
+
14
|
| 1217 |
+
],
|
| 1218 |
+
[
|
| 1219 |
+
33,
|
| 1220 |
+
24
|
| 1221 |
+
],
|
| 1222 |
+
[
|
| 1223 |
+
4,
|
| 1224 |
+
3
|
| 1225 |
+
],
|
| 1226 |
+
[
|
| 1227 |
+
22,
|
| 1228 |
+
47
|
| 1229 |
+
],
|
| 1230 |
+
[
|
| 1231 |
+
35,
|
| 1232 |
+
4
|
| 1233 |
+
],
|
| 1234 |
+
[
|
| 1235 |
+
19,
|
| 1236 |
+
50
|
| 1237 |
+
],
|
| 1238 |
+
[
|
| 1239 |
+
31,
|
| 1240 |
+
34
|
| 1241 |
+
],
|
| 1242 |
+
[
|
| 1243 |
+
28,
|
| 1244 |
+
45
|
| 1245 |
+
],
|
| 1246 |
+
[
|
| 1247 |
+
28,
|
| 1248 |
+
43
|
| 1249 |
+
]
|
| 1250 |
+
]
|
| 1251 |
+
],
|
| 1252 |
+
"output": 230998762
|
| 1253 |
+
},
|
| 1254 |
+
{
|
| 1255 |
+
"input": [
|
| 1256 |
+
173,
|
| 1257 |
+
[
|
| 1258 |
+
[
|
| 1259 |
+
16,
|
| 1260 |
+
26
|
| 1261 |
+
],
|
| 1262 |
+
[
|
| 1263 |
+
26,
|
| 1264 |
+
5
|
| 1265 |
+
],
|
| 1266 |
+
[
|
| 1267 |
+
49,
|
| 1268 |
+
1
|
| 1269 |
+
],
|
| 1270 |
+
[
|
| 1271 |
+
4,
|
| 1272 |
+
11
|
| 1273 |
+
],
|
| 1274 |
+
[
|
| 1275 |
+
31,
|
| 1276 |
+
44
|
| 1277 |
+
],
|
| 1278 |
+
[
|
| 1279 |
+
35,
|
| 1280 |
+
16
|
| 1281 |
+
],
|
| 1282 |
+
[
|
| 1283 |
+
48,
|
| 1284 |
+
25
|
| 1285 |
+
],
|
| 1286 |
+
[
|
| 1287 |
+
20,
|
| 1288 |
+
49
|
| 1289 |
+
]
|
| 1290 |
+
]
|
| 1291 |
+
],
|
| 1292 |
+
"output": 7298
|
| 1293 |
+
}
|
| 1294 |
+
],
|
| 1295 |
+
"haskell_template": "waysToReachTarget :: Int -> [[Int]] -> Int\nwaysToReachTarget target types ",
|
| 1296 |
+
"ocaml_template": "let waysToReachTarget (target: int) (types: int list list) : int = ",
|
| 1297 |
+
"scala_template": "def waysToReachTarget(target: Int,types: List[List[Int]]): Int = { \n \n}",
|
| 1298 |
+
"java_template": "public static int waysToReachTarget(int target, List<List<Integer>> types) {\n\n}",
|
| 1299 |
+
"python_template": "class Solution(object):\n def waysToReachTarget(self, target, types):\n \"\"\"\n :type target: int\n :type types: List[List[int]]\n :rtype: int\n \"\"\"\n "
|
| 1300 |
+
}
|
number_of_ways_to_earn_points/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 7 (waysToReachTarget 6 [[6;1];[3;2];[2;3]])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 4 (waysToReachTarget 5 [[50;1];[50;2];[50;5]])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 1 (waysToReachTarget 18 [[6;1];[3;2];[2;3]])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for waysToReachTarget" >::: [
|
| 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_ways_to_earn_points/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.waysToReachTarget(6,List(List(6,1),List(3,2),List(2,3))), 7)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.waysToReachTarget(5,List(List(50,1),List(50,2),List(50,5))), 4)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.waysToReachTarget(18,List(List(6,1),List(3,2),List(2,3))), 1)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
number_of_ways_to_reach_a_position_after_exactly_k_steps/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_ways_to_reach_a_position_after_exactly_k_steps/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 (numberOfWays 1 2 3)," 3 (numberOfWays 1 2 3))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numberOfWays 2 5 10)," 0 (numberOfWays 2 5 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_ways_to_reach_a_position_after_exactly_k_steps/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, numberOfWays(1, 2, 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(0, numberOfWays(2, 5, 10));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
number_of_ways_to_reach_a_position_after_exactly_k_steps/meta.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2477,
|
| 3 |
+
"name": "number_of_ways_to_reach_a_position_after_exactly_k_steps",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/",
|
| 6 |
+
"date": "1661644800000",
|
| 7 |
+
"task_description": "You are given two **positive** integers `startPos` and `endPos`. Initially, you are standing at position `startPos` on an **infinite** number line. With one step, you can move either one position to the left, or one position to the right. Given a positive integer `k`, return _the number of **different** ways to reach the position _`endPos`_ starting from _`startPos`_, such that you perform **exactly** _`k`_ steps_. Since the answer may be very large, return it **modulo** `109 + 7`. Two ways are considered different if the order of the steps made is not exactly the same. **Note** that the number line includes negative integers. **Example 1:** ``` **Input:** startPos = 1, endPos = 2, k = 3 **Output:** 3 **Explanation:** We can reach position 2 from 1 in exactly 3 steps in three ways: - 1 -> 2 -> 3 -> 2. - 1 -> 2 -> 1 -> 2. - 1 -> 0 -> 1 -> 2. It can be proven that no other way is possible, so we return 3. ``` **Example 2:** ``` **Input:** startPos = 2, endPos = 5, k = 10 **Output:** 0 **Explanation:** It is impossible to reach position 5 from position 2 in exactly 10 steps. ``` **Constraints:** `1 <= startPos, endPos, k <= 1000`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "startPos = 1, endPos = 2, k = 3",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "startPos = 2, endPos = 5, k = 10",
|
| 17 |
+
"output": "0 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
67,
|
| 24 |
+
535,
|
| 25 |
+
157
|
| 26 |
+
],
|
| 27 |
+
"output": 0
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"input": [
|
| 31 |
+
67,
|
| 32 |
+
426,
|
| 33 |
+
905
|
| 34 |
+
],
|
| 35 |
+
"output": 478687450
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"input": [
|
| 39 |
+
670,
|
| 40 |
+
912,
|
| 41 |
+
370
|
| 42 |
+
],
|
| 43 |
+
"output": 945230893
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"input": [
|
| 47 |
+
164,
|
| 48 |
+
96,
|
| 49 |
+
789
|
| 50 |
+
],
|
| 51 |
+
"output": 0
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"input": [
|
| 55 |
+
57,
|
| 56 |
+
796,
|
| 57 |
+
866
|
| 58 |
+
],
|
| 59 |
+
"output": 0
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"input": [
|
| 63 |
+
105,
|
| 64 |
+
690,
|
| 65 |
+
749
|
| 66 |
+
],
|
| 67 |
+
"output": 435423671
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"input": [
|
| 71 |
+
281,
|
| 72 |
+
224,
|
| 73 |
+
7
|
| 74 |
+
],
|
| 75 |
+
"output": 0
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"input": [
|
| 79 |
+
86,
|
| 80 |
+
331,
|
| 81 |
+
691
|
| 82 |
+
],
|
| 83 |
+
"output": 156456068
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"input": [
|
| 87 |
+
489,
|
| 88 |
+
72,
|
| 89 |
+
188
|
| 90 |
+
],
|
| 91 |
+
"output": 0
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"input": [
|
| 95 |
+
385,
|
| 96 |
+
136,
|
| 97 |
+
541
|
| 98 |
+
],
|
| 99 |
+
"output": 678519907
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
"haskell_template": "numberOfWays :: Int -> Int -> Int -> Int\nnumberOfWays startPos endPos k ",
|
| 103 |
+
"ocaml_template": "let numberOfWays (startPos: int) (endPos: int) (k: int) : int = ",
|
| 104 |
+
"scala_template": "def numberOfWays(startPos: Int,endPos: Int,k: Int): Int = { \n \n}",
|
| 105 |
+
"java_template": "public static int numberOfWays(int startPos, int endPos, int k) {\n\n}",
|
| 106 |
+
"python_template": "class Solution(object):\n def numberOfWays(self, startPos, endPos, k):\n \"\"\"\n :type startPos: int\n :type endPos: int\n :type k: int\n :rtype: int\n \"\"\"\n "
|
| 107 |
+
}
|
number_of_ways_to_reach_a_position_after_exactly_k_steps/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 (numberOfWays 1 2 3)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 0 (numberOfWays 2 5 10)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for numberOfWays" >::: [
|
| 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_ways_to_reach_a_position_after_exactly_k_steps/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numberOfWays(1,2,3), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numberOfWays(2,5,10), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_ways_to_select_buildings/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_ways_to_select_buildings/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 (numberOfWays \"001101 \")," 6 (numberOfWays "001101"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numberOfWays \"11100 \")," 0 (numberOfWays "11100"))
|
| 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_ways_to_select_buildings/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(6, numberOfWays("001101"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(0, numberOfWays("11100"));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
number_of_ways_to_select_buildings/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_ways_to_select_buildings/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 6 (numberOfWays "001101")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 0 (numberOfWays "11100")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for numberOfWays" >::: [
|
| 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_ways_to_select_buildings/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numberOfWays("001101"), 6)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numberOfWays("11100"), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_ways_to_split_array/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_ways_to_split_array/java_tests/Main.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(2, waysToSplitArray(Arrays.asList(10,4,-8,7)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(2, waysToSplitArray(Arrays.asList(2,3,1,0)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
number_of_ways_to_split_array/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_ways_to_split_array/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_ways_to_split_array/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
number_of_zero_filled_subarrays/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_zero_filled_subarrays/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 (zeroFilledSubarray [1,3,0,0,2,0,0,4])," 6 (zeroFilledSubarray [1,3,0,0,2,0,0,4]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (zeroFilledSubarray [0,0,0,2,0,0])," 9 (zeroFilledSubarray [0,0,0,2,0,0]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (zeroFilledSubarray [2,10,2019])," 0 (zeroFilledSubarray [2,10,2019]))
|
| 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_zero_filled_subarrays/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, zeroFilledSubarray(new ArrayList<>(Arrays.asList(1,3,0,0,2,0,0,4))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(9, zeroFilledSubarray(new ArrayList<>(Arrays.asList(0,0,0,2,0,0))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(0, zeroFilledSubarray(new ArrayList<>(Arrays.asList(2,10,2019))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
number_of_zero_filled_subarrays/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a98970be3140afb9614677b3ab63bfdd2c876c1232917c90f4f891af5b804dbd
|
| 3 |
+
size 10953851
|
number_of_zero_filled_subarrays/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 (zeroFilledSubarray [1;3;0;0;2;0;0;4])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 9 (zeroFilledSubarray [0;0;0;2;0;0])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 0 (zeroFilledSubarray [2;10;2019])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for zeroFilledSubarray" >::: [
|
| 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
|