DatasetRepo commited on
Commit
bf3bec3
·
verified ·
1 Parent(s): 2508fb2

0ffe00eb80825987deb6309da960a8a9552940ddfc60de62fc1020028fb2c4ab

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 +3 -0
  2. largest_positive_integer_that_exists_with_its_negative/scala_tests/MySuite.scala +16 -0
  3. last_visited_integers/haskell_tests/Main.hs +47 -0
  4. last_visited_integers/java_tests/Main.java +20 -0
  5. last_visited_integers/meta.json +590 -0
  6. last_visited_integers/ocaml_tests/main.ml +51 -0
  7. last_visited_integers/scala_tests/MySuite.scala +44 -0
  8. latest_time_you_can_obtain_after_replacing_characters/haskell_tests/Main.hs +41 -0
  9. latest_time_you_can_obtain_after_replacing_characters/java_tests/Main.java +20 -0
  10. latest_time_you_can_obtain_after_replacing_characters/meta.json +47 -0
  11. latest_time_you_can_obtain_after_replacing_characters/ocaml_tests/main.ml +42 -0
  12. latest_time_you_can_obtain_after_replacing_characters/scala_tests/MySuite.scala +32 -0
  13. left_and_right_sum_differences/.DS_Store +0 -0
  14. left_and_right_sum_differences/haskell_tests/Main.hs +24 -0
  15. left_and_right_sum_differences/java_tests/Main.java +21 -0
  16. left_and_right_sum_differences/meta.json +0 -0
  17. left_and_right_sum_differences/ocaml_tests/main.ml +26 -0
  18. left_and_right_sum_differences/scala_tests/MySuite.scala +12 -0
  19. length_of_longest_subarray_with_at_most_k_frequency/haskell_tests/Main.hs +0 -0
  20. length_of_longest_subarray_with_at_most_k_frequency/java_tests/Main.java +25 -0
  21. length_of_longest_subarray_with_at_most_k_frequency/meta.json +3 -0
  22. length_of_longest_subarray_with_at_most_k_frequency/ocaml_tests/main.ml +0 -0
  23. length_of_longest_subarray_with_at_most_k_frequency/scala_tests/MySuite.scala +0 -0
  24. length_of_longest_v_shaped_diagonal_segment/haskell_tests/Main.hs +0 -0
  25. length_of_longest_v_shaped_diagonal_segment/java_tests/Main.java +28 -0
  26. length_of_longest_v_shaped_diagonal_segment/meta.json +0 -0
  27. length_of_longest_v_shaped_diagonal_segment/ocaml_tests/main.ml +0 -0
  28. length_of_longest_v_shaped_diagonal_segment/scala_tests/MySuite.scala +0 -0
  29. length_of_the_longest_alphabetical_continuous_substring/haskell_tests/Main.hs +0 -0
  30. length_of_the_longest_alphabetical_continuous_substring/java_tests/Main.java +20 -0
  31. length_of_the_longest_alphabetical_continuous_substring/meta.json +0 -0
  32. length_of_the_longest_alphabetical_continuous_substring/ocaml_tests/main.ml +0 -0
  33. length_of_the_longest_alphabetical_continuous_substring/scala_tests/MySuite.scala +0 -0
  34. length_of_the_longest_increasing_path/haskell_tests/Main.hs +3 -0
  35. length_of_the_longest_increasing_path/java_tests/Main.java +21 -0
  36. length_of_the_longest_increasing_path/meta.json +3 -0
  37. length_of_the_longest_increasing_path/ocaml_tests/main.ml +0 -0
  38. length_of_the_longest_increasing_path/scala_tests/MySuite.scala +0 -0
  39. length_of_the_longest_subsequence_that_sums_to_target/haskell_tests/Main.hs +45 -0
  40. length_of_the_longest_subsequence_that_sums_to_target/java_tests/Main.java +25 -0
  41. length_of_the_longest_subsequence_that_sums_to_target/meta.json +0 -0
  42. length_of_the_longest_subsequence_that_sums_to_target/ocaml_tests/main.ml +50 -0
  43. length_of_the_longest_subsequence_that_sums_to_target/scala_tests/MySuite.scala +44 -0
  44. length_of_the_longest_valid_substring/.DS_Store +0 -0
  45. length_of_the_longest_valid_substring/haskell_tests/Main.hs +24 -0
  46. length_of_the_longest_valid_substring/java_tests/Main.java +21 -0
  47. length_of_the_longest_valid_substring/meta.json +26 -0
  48. length_of_the_longest_valid_substring/ocaml_tests/main.ml +26 -0
  49. length_of_the_longest_valid_substring/scala_tests/MySuite.scala +12 -0
  50. lexicographically_minimum_string_after_removing_stars/haskell_tests/Main.hs +41 -0
.gitattributes CHANGED
@@ -142,3 +142,6 @@ k_th_nearest_obstacle_queries/haskell_tests/Main.hs filter=lfs diff=lfs merge=lf
142
  k_th_nearest_obstacle_queries/meta.json filter=lfs diff=lfs merge=lfs -text
143
  largest_combination_with_bitwise_and_greater_than_zero/meta.json filter=lfs diff=lfs merge=lfs -text
144
  largest_element_in_an_array_after_merge_operations/meta.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
142
  k_th_nearest_obstacle_queries/meta.json filter=lfs diff=lfs merge=lfs -text
143
  largest_combination_with_bitwise_and_greater_than_zero/meta.json filter=lfs diff=lfs merge=lfs -text
144
  largest_element_in_an_array_after_merge_operations/meta.json filter=lfs diff=lfs merge=lfs -text
145
+ length_of_longest_subarray_with_at_most_k_frequency/meta.json filter=lfs diff=lfs merge=lfs -text
146
+ length_of_the_longest_increasing_path/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
147
+ length_of_the_longest_increasing_path/meta.json filter=lfs diff=lfs merge=lfs -text
largest_positive_integer_that_exists_with_its_negative/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findMaxK(List(-1,2,-3,3)), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findMaxK(List(-1,10,6,7,-7,1)), 7)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findMaxK(List(-10,8,6,7,-2,-3)), -1)
14
+ }
15
+
16
+ }
last_visited_integers/haskell_tests/Main.hs ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ lastVisitedIntegers :: [Int] -> [Int]
7
+ lastVisitedIntegers nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (lastVisitedIntegers [1,2,-1,-1,-1])," [2,1,-1] (lastVisitedIntegers [1,2,-1,-1,-1]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (lastVisitedIntegers [1,-1,2,-1,-1])," [1,2,1] (lastVisitedIntegers [1,-1,2,-1,-1]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (lastVisitedIntegers [-1, ( -1), 3, 97, 3, 35, ( -1), 94, ( -1), 16, 58, ( -1), ( -1), ( -1), ( -1), 21, ( -1), ( -1), ( -1), ( -1), 97, ( -1), 94, 17, 94, 68, ( -1), 12, 35, 96, ( -1)])," [] (lastVisitedIntegers [-1, -1, 3, 97, 3, 35, -1, 94, -1, 16, 58, -1, -1, -1, -1, 21, -1, -1, -1, -1, 97, -1, 94, 17, 94, 68, -1, 12, 35, 96, -1]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (lastVisitedIntegers [-1, ( -1), 91, ( -1), 9, 54, ( -1), ( -1), 44, 13, 87, ( -1), 2, ( -1), ( -1), 40, ( -1), ( -1), 84, 36, ( -1), ( -1)])," [] (lastVisitedIntegers [-1, -1, 91, -1, 9, 54, -1, -1, 44, 13, 87, -1, 2, -1, -1, 40, -1, -1, 84, 36, -1, -1]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (lastVisitedIntegers [-1, 48, ( -1), 95, 86, ( -1), 52, 78, 84, ( -1), ( -1), ( -1), 90, ( -1), 23, ( -1), ( -1), 70, ( -1), 23, ( -1), ( -1), 60, ( -1), 13, ( -1), ( -1), ( -1), 14, 40, ( -1), 95, ( -1), 46, 53, ( -1), 61, 12, 95, ( -1), 48, 99, 89, ( -1), 49, 26, 55, ( -1), ( -1), 58, 17, 53, ( -1), ( -1), 34, ( -1), ( -1), 19, 98, ( -1), ( -1), ( -1), ( -1), ( -1), 82, 93, 70, ( -1), ( -1), 63, 59, ( -1), 59, 68, ( -1), ( -1), 48, 66, ( -1), ( -1), 11, ( -1), 42, ( -1), 10, ( -1), 21, ( -1), ( -1), 61, ( -1), ( -1), 96])," [] (lastVisitedIntegers [-1, 48, -1, 95, 86, -1, 52, 78, 84, -1, -1, -1, 90, -1, 23, -1, -1, 70, -1, 23, -1, -1, 60, -1, 13, -1, -1, -1, 14, 40, -1, 95, -1, 46, 53, -1, 61, 12, 95, -1, 48, 99, 89, -1, 49, 26, 55, -1, -1, 58, 17, 53, -1, -1, 34, -1, -1, 19, 98, -1, -1, -1, -1, -1, 82, 93, 70, -1, -1, 63, 59, -1, 59, 68, -1, -1, 48, 66, -1, -1, 11, -1, 42, -1, 10, -1, 21, -1, -1, 61, -1, -1, 96]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (lastVisitedIntegers [9, ( -1), ( -1), ( -1), 86, 66, ( -1), ( -1), ( -1), 17, 16, ( -1), ( -1), ( -1), ( -1), ( -1), 25, ( -1), ( -1), 75, ( -1), ( -1), 40, 55, 98, ( -1), 15])," [] (lastVisitedIntegers [9, -1, -1, -1, 86, 66, -1, -1, -1, 17, 16, -1, -1, -1, -1, -1, 25, -1, -1, 75, -1, -1, 40, 55, 98, -1, 15]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (lastVisitedIntegers [32, ( -1), 81, 45, ( -1), 70, ( -1), ( -1), 27, 2, 39, ( -1), ( -1), 44, 18, 50, ( -1), ( -1), 55, 31, 72, ( -1), 14, 86, 18, 54, 100, ( -1), 19, 95, 5, 44, ( -1), 16, 89, ( -1), 35, ( -1), 75, 6, ( -1), ( -1), 10, 94, ( -1), 72, ( -1), 59, 89, 90, 51, 34, 58, 7, ( -1), ( -1), ( -1), 93, 50, 55])," [] (lastVisitedIntegers [32, -1, 81, 45, -1, 70, -1, -1, 27, 2, 39, -1, -1, 44, 18, 50, -1, -1, 55, 31, 72, -1, 14, 86, 18, 54, 100, -1, 19, 95, 5, 44, -1, 16, 89, -1, 35, -1, 75, 6, -1, -1, 10, 94, -1, 72, -1, 59, 89, 90, 51, 34, 58, 7, -1, -1, -1, 93, 50, 55]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (lastVisitedIntegers [-1, ( -1), 11, ( -1), 6, ( -1), ( -1), 22, 26, ( -1), ( -1), 92, 62, ( -1), ( -1), 5, 90, 76, ( -1), ( -1), ( -1), 43, 85, ( -1), 89, ( -1), ( -1), ( -1), ( -1), ( -1), ( -1), 15, 47, 6, ( -1), ( -1), ( -1), 34, ( -1), ( -1), 80, 49, ( -1), 36, 84, ( -1), 87, 53, ( -1), ( -1), ( -1), 39, 20, 71, 52, 16, 43, 91, ( -1), ( -1), 99, 22, ( -1), 84, 95, ( -1), ( -1), ( -1), ( -1), 42, ( -1), ( -1), 23, 81, 29, ( -1), 45, ( -1), 36, ( -1), 13, 42, ( -1), 77, 71, 75, 71, ( -1), ( -1), 15, ( -1), 43, 19, 16, 40, ( -1), ( -1), 55, ( -1)])," [] (lastVisitedIntegers [-1, -1, 11, -1, 6, -1, -1, 22, 26, -1, -1, 92, 62, -1, -1, 5, 90, 76, -1, -1, -1, 43, 85, -1, 89, -1, -1, -1, -1, -1, -1, 15, 47, 6, -1, -1, -1, 34, -1, -1, 80, 49, -1, 36, 84, -1, 87, 53, -1, -1, -1, 39, 20, 71, 52, 16, 43, 91, -1, -1, 99, 22, -1, 84, 95, -1, -1, -1, -1, 42, -1, -1, 23, 81, 29, -1, 45, -1, 36, -1, 13, 42, -1, 77, 71, 75, 71, -1, -1, 15, -1, 43, 19, 16, 40, -1, -1, 55, -1]))
36
+
37
+ test9 :: Test
38
+ test9 = TestCase (assertEqual "for (lastVisitedIntegers [-1, ( -1), 96, 41, ( -1), 68, 9, 89, 2, ( -1), ( -1), 9, ( -1), ( -1), 31, ( -1), ( -1), 90, 81, ( -1), ( -1), ( -1), 43, 85, ( -1), ( -1), ( -1), ( -1), ( -1), 77, ( -1), ( -1), ( -1), ( -1), 59, 52, 86, ( -1), ( -1), ( -1), 28, 23, ( -1), ( -1), 46, 55, ( -1), ( -1), 69, 23, ( -1), ( -1), ( -1), ( -1), 42, ( -1), ( -1), 38, 52, ( -1), 57])," [] (lastVisitedIntegers [-1, -1, 96, 41, -1, 68, 9, 89, 2, -1, -1, 9, -1, -1, 31, -1, -1, 90, 81, -1, -1, -1, 43, 85, -1, -1, -1, -1, -1, 77, -1, -1, -1, -1, 59, 52, 86, -1, -1, -1, 28, 23, -1, -1, 46, 55, -1, -1, 69, 23, -1, -1, -1, -1, 42, -1, -1, 38, 52, -1, 57]))
39
+
40
+
41
+ -- Grouping test cases
42
+ tests :: Test
43
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
44
+
45
+ -- Running the tests
46
+ main :: IO Counts
47
+ main = runTestTT tests
last_visited_integers/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(Arrays.asList(2,1,-1), lastVisitedIntegers(Arrays.asList(1,2,-1,-1,-1)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(Arrays.asList(1,2,1), lastVisitedIntegers(Arrays.asList(1,-1,2,-1,-1)));
18
+ }
19
+
20
+ }
last_visited_integers/meta.json ADDED
@@ -0,0 +1,590 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3164,
3
+ "name": "last_visited_integers",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/last-visited-integers/",
6
+ "date": "2023-09-30 00:00:00",
7
+ "task_description": "Given an integer array `nums` where `nums[i]` is either a positive integer or `-1`. We need to find for each `-1` the respective positive integer, which we call the last visited integer. To achieve this goal, let's define two empty arrays: `seen` and `ans`. Start iterating from the beginning of the array `nums`. If a positive integer is encountered, prepend it to the **front** of `seen`. If `-1` is encountered, let `k` be the number of **consecutive** `-1`s seen so far (including the current `-1`), If `k` is less than or equal to the length of `seen`, append the `k`-th element of `seen` to `ans`. If `k` is strictly greater than the length of `seen`, append `-1` to `ans`. Return the array_ _`ans`. **Example 1:** **Input:** nums = [1,2,-1,-1,-1] **Output:** [2,1,-1] **Explanation:** Start with `seen = []` and `ans = []`. Process `nums[0]`: The first element in nums is `1`. We prepend it to the front of `seen`. Now, `seen == [1]`. Process `nums[1]`: The next element is `2`. We prepend it to the front of `seen`. Now, `seen == [2, 1]`. Process `nums[2]`: The next element is `-1`. This is the first occurrence of `-1`, so `k == 1`. We look for the first element in seen. We append `2` to `ans`. Now, `ans == [2]`. Process `nums[3]`: Another `-1`. This is the second consecutive `-1`, so `k == 2`. The second element in `seen` is `1`, so we append `1` to `ans`. Now, `ans == [2, 1]`. Process `nums[4]`: Another `-1`, the third in a row, making `k = 3`. However, `seen` only has two elements (`[2, 1]`). Since `k` is greater than the number of elements in `seen`, we append `-1` to `ans`. Finally, `ans == [2, 1, -1]`. **Example 2:** **Input:** nums = [1,-1,2,-1,-1] **Output:** [1,2,1] **Explanation:** Start with `seen = []` and `ans = []`. Process `nums[0]`: The first element in nums is `1`. We prepend it to the front of `seen`. Now, `seen == [1]`. Process `nums[1]`: The next element is `-1`. This is the first occurrence of `-1`, so `k == 1`. We look for the first element in `seen`, which is `1`. Append `1` to `ans`. Now, `ans == [1]`. Process `nums[2]`: The next element is `2`. Prepend this to the front of `seen`. Now, `seen == [2, 1]`. Process `nums[3]`: The next element is `-1`. This `-1` is not consecutive to the first `-1` since `2` was in between. Thus, `k` resets to `1`. The first element in `seen` is `2`, so append `2` to `ans`. Now, `ans == [1, 2]`. Process `nums[4]`: Another `-1`. This is consecutive to the previous `-1`, so `k == 2`. The second element in `seen` is `1`, append `1` to `ans`. Finally, `ans == [1, 2, 1]`. **Constraints:** `1 <= nums.length <= 100` `nums[i] == -1` or `1 <= nums[i] <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,2,-1,-1,-1]",
12
+ "output": "[2,1,-1] "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,-1,2,-1,-1]",
17
+ "output": "[1,2,1] "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ -1,
24
+ -1,
25
+ 3,
26
+ 97,
27
+ 3,
28
+ 35,
29
+ -1,
30
+ 94,
31
+ -1,
32
+ 16,
33
+ 58,
34
+ -1,
35
+ -1,
36
+ -1,
37
+ -1,
38
+ 21,
39
+ -1,
40
+ -1,
41
+ -1,
42
+ -1,
43
+ 97,
44
+ -1,
45
+ 94,
46
+ 17,
47
+ 94,
48
+ 68,
49
+ -1,
50
+ 12,
51
+ 35,
52
+ 96,
53
+ -1
54
+ ],
55
+ "output": []
56
+ },
57
+ {
58
+ "input": [
59
+ -1,
60
+ -1,
61
+ 91,
62
+ -1,
63
+ 9,
64
+ 54,
65
+ -1,
66
+ -1,
67
+ 44,
68
+ 13,
69
+ 87,
70
+ -1,
71
+ 2,
72
+ -1,
73
+ -1,
74
+ 40,
75
+ -1,
76
+ -1,
77
+ 84,
78
+ 36,
79
+ -1,
80
+ -1
81
+ ],
82
+ "output": []
83
+ },
84
+ {
85
+ "input": [
86
+ -1,
87
+ 48,
88
+ -1,
89
+ 95,
90
+ 86,
91
+ -1,
92
+ 52,
93
+ 78,
94
+ 84,
95
+ -1,
96
+ -1,
97
+ -1,
98
+ 90,
99
+ -1,
100
+ 23,
101
+ -1,
102
+ -1,
103
+ 70,
104
+ -1,
105
+ 23,
106
+ -1,
107
+ -1,
108
+ 60,
109
+ -1,
110
+ 13,
111
+ -1,
112
+ -1,
113
+ -1,
114
+ 14,
115
+ 40,
116
+ -1,
117
+ 95,
118
+ -1,
119
+ 46,
120
+ 53,
121
+ -1,
122
+ 61,
123
+ 12,
124
+ 95,
125
+ -1,
126
+ 48,
127
+ 99,
128
+ 89,
129
+ -1,
130
+ 49,
131
+ 26,
132
+ 55,
133
+ -1,
134
+ -1,
135
+ 58,
136
+ 17,
137
+ 53,
138
+ -1,
139
+ -1,
140
+ 34,
141
+ -1,
142
+ -1,
143
+ 19,
144
+ 98,
145
+ -1,
146
+ -1,
147
+ -1,
148
+ -1,
149
+ -1,
150
+ 82,
151
+ 93,
152
+ 70,
153
+ -1,
154
+ -1,
155
+ 63,
156
+ 59,
157
+ -1,
158
+ 59,
159
+ 68,
160
+ -1,
161
+ -1,
162
+ 48,
163
+ 66,
164
+ -1,
165
+ -1,
166
+ 11,
167
+ -1,
168
+ 42,
169
+ -1,
170
+ 10,
171
+ -1,
172
+ 21,
173
+ -1,
174
+ -1,
175
+ 61,
176
+ -1,
177
+ -1,
178
+ 96
179
+ ],
180
+ "output": []
181
+ },
182
+ {
183
+ "input": [
184
+ 9,
185
+ -1,
186
+ -1,
187
+ -1,
188
+ 86,
189
+ 66,
190
+ -1,
191
+ -1,
192
+ -1,
193
+ 17,
194
+ 16,
195
+ -1,
196
+ -1,
197
+ -1,
198
+ -1,
199
+ -1,
200
+ 25,
201
+ -1,
202
+ -1,
203
+ 75,
204
+ -1,
205
+ -1,
206
+ 40,
207
+ 55,
208
+ 98,
209
+ -1,
210
+ 15
211
+ ],
212
+ "output": []
213
+ },
214
+ {
215
+ "input": [
216
+ 32,
217
+ -1,
218
+ 81,
219
+ 45,
220
+ -1,
221
+ 70,
222
+ -1,
223
+ -1,
224
+ 27,
225
+ 2,
226
+ 39,
227
+ -1,
228
+ -1,
229
+ 44,
230
+ 18,
231
+ 50,
232
+ -1,
233
+ -1,
234
+ 55,
235
+ 31,
236
+ 72,
237
+ -1,
238
+ 14,
239
+ 86,
240
+ 18,
241
+ 54,
242
+ 100,
243
+ -1,
244
+ 19,
245
+ 95,
246
+ 5,
247
+ 44,
248
+ -1,
249
+ 16,
250
+ 89,
251
+ -1,
252
+ 35,
253
+ -1,
254
+ 75,
255
+ 6,
256
+ -1,
257
+ -1,
258
+ 10,
259
+ 94,
260
+ -1,
261
+ 72,
262
+ -1,
263
+ 59,
264
+ 89,
265
+ 90,
266
+ 51,
267
+ 34,
268
+ 58,
269
+ 7,
270
+ -1,
271
+ -1,
272
+ -1,
273
+ 93,
274
+ 50,
275
+ 55
276
+ ],
277
+ "output": []
278
+ },
279
+ {
280
+ "input": [
281
+ -1,
282
+ -1,
283
+ 11,
284
+ -1,
285
+ 6,
286
+ -1,
287
+ -1,
288
+ 22,
289
+ 26,
290
+ -1,
291
+ -1,
292
+ 92,
293
+ 62,
294
+ -1,
295
+ -1,
296
+ 5,
297
+ 90,
298
+ 76,
299
+ -1,
300
+ -1,
301
+ -1,
302
+ 43,
303
+ 85,
304
+ -1,
305
+ 89,
306
+ -1,
307
+ -1,
308
+ -1,
309
+ -1,
310
+ -1,
311
+ -1,
312
+ 15,
313
+ 47,
314
+ 6,
315
+ -1,
316
+ -1,
317
+ -1,
318
+ 34,
319
+ -1,
320
+ -1,
321
+ 80,
322
+ 49,
323
+ -1,
324
+ 36,
325
+ 84,
326
+ -1,
327
+ 87,
328
+ 53,
329
+ -1,
330
+ -1,
331
+ -1,
332
+ 39,
333
+ 20,
334
+ 71,
335
+ 52,
336
+ 16,
337
+ 43,
338
+ 91,
339
+ -1,
340
+ -1,
341
+ 99,
342
+ 22,
343
+ -1,
344
+ 84,
345
+ 95,
346
+ -1,
347
+ -1,
348
+ -1,
349
+ -1,
350
+ 42,
351
+ -1,
352
+ -1,
353
+ 23,
354
+ 81,
355
+ 29,
356
+ -1,
357
+ 45,
358
+ -1,
359
+ 36,
360
+ -1,
361
+ 13,
362
+ 42,
363
+ -1,
364
+ 77,
365
+ 71,
366
+ 75,
367
+ 71,
368
+ -1,
369
+ -1,
370
+ 15,
371
+ -1,
372
+ 43,
373
+ 19,
374
+ 16,
375
+ 40,
376
+ -1,
377
+ -1,
378
+ 55,
379
+ -1
380
+ ],
381
+ "output": []
382
+ },
383
+ {
384
+ "input": [
385
+ -1,
386
+ -1,
387
+ 96,
388
+ 41,
389
+ -1,
390
+ 68,
391
+ 9,
392
+ 89,
393
+ 2,
394
+ -1,
395
+ -1,
396
+ 9,
397
+ -1,
398
+ -1,
399
+ 31,
400
+ -1,
401
+ -1,
402
+ 90,
403
+ 81,
404
+ -1,
405
+ -1,
406
+ -1,
407
+ 43,
408
+ 85,
409
+ -1,
410
+ -1,
411
+ -1,
412
+ -1,
413
+ -1,
414
+ 77,
415
+ -1,
416
+ -1,
417
+ -1,
418
+ -1,
419
+ 59,
420
+ 52,
421
+ 86,
422
+ -1,
423
+ -1,
424
+ -1,
425
+ 28,
426
+ 23,
427
+ -1,
428
+ -1,
429
+ 46,
430
+ 55,
431
+ -1,
432
+ -1,
433
+ 69,
434
+ 23,
435
+ -1,
436
+ -1,
437
+ -1,
438
+ -1,
439
+ 42,
440
+ -1,
441
+ -1,
442
+ 38,
443
+ 52,
444
+ -1,
445
+ 57
446
+ ],
447
+ "output": []
448
+ },
449
+ {
450
+ "input": [
451
+ 39,
452
+ -1,
453
+ 1,
454
+ 13,
455
+ 23,
456
+ 47,
457
+ 21,
458
+ -1,
459
+ 3,
460
+ 68,
461
+ 51,
462
+ 95,
463
+ -1,
464
+ -1,
465
+ 40,
466
+ -1,
467
+ 18,
468
+ 38,
469
+ -1,
470
+ 96,
471
+ 3,
472
+ -1,
473
+ -1,
474
+ -1,
475
+ -1,
476
+ 85,
477
+ -1,
478
+ 96,
479
+ 95,
480
+ 77,
481
+ -1,
482
+ -1,
483
+ 35,
484
+ -1,
485
+ -1,
486
+ 81,
487
+ -1,
488
+ -1,
489
+ -1,
490
+ -1,
491
+ 8,
492
+ 34,
493
+ 86,
494
+ -1,
495
+ -1,
496
+ -1,
497
+ -1,
498
+ 4,
499
+ -1,
500
+ -1,
501
+ 4,
502
+ 3,
503
+ -1,
504
+ -1,
505
+ 100,
506
+ 11,
507
+ 4,
508
+ -1,
509
+ -1,
510
+ 55,
511
+ 70,
512
+ -1,
513
+ 90,
514
+ 69,
515
+ -1,
516
+ -1,
517
+ -1,
518
+ -1,
519
+ 34,
520
+ -1,
521
+ -1,
522
+ 2,
523
+ 94,
524
+ 45,
525
+ -1,
526
+ -1,
527
+ 2,
528
+ -1,
529
+ 49,
530
+ -1,
531
+ -1,
532
+ -1,
533
+ 9
534
+ ],
535
+ "output": []
536
+ },
537
+ {
538
+ "input": [
539
+ 88,
540
+ 83,
541
+ 80
542
+ ],
543
+ "output": []
544
+ },
545
+ {
546
+ "input": [
547
+ 75,
548
+ 61,
549
+ 2,
550
+ -1,
551
+ 13,
552
+ -1,
553
+ 88,
554
+ -1,
555
+ -1,
556
+ 78,
557
+ 58,
558
+ -1,
559
+ 54,
560
+ 7,
561
+ -1,
562
+ -1,
563
+ 9,
564
+ -1,
565
+ 37,
566
+ -1,
567
+ 93,
568
+ 90,
569
+ 12,
570
+ -1,
571
+ 26,
572
+ -1,
573
+ -1,
574
+ -1,
575
+ -1,
576
+ -1,
577
+ 63,
578
+ 60,
579
+ 67,
580
+ 37
581
+ ],
582
+ "output": []
583
+ }
584
+ ],
585
+ "haskell_template": "lastVisitedIntegers :: [Int] -> [Int]\nlastVisitedIntegers nums ",
586
+ "ocaml_template": "let lastVisitedIntegers (nums: int list) : int list = ",
587
+ "scala_template": "def lastVisitedIntegers(nums: List[Int]): List[Int] = { \n \n}",
588
+ "java_template": "class Solution {\n public List<Integer> lastVisitedIntegers(int[] nums) {\n \n }\n}",
589
+ "python_template": "class Solution(object):\n def lastVisitedIntegers(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n \"\"\"\n "
590
+ }
last_visited_integers/ocaml_tests/main.ml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let lastVisitedIntegers (nums: int list) : int list = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal [2;1;-1] (lastVisitedIntegers [1;2;-1;-1;-1])
13
+
14
+ let test2 _ = assert_equal [1;2;1] (lastVisitedIntegers [1;-1;2;-1;-1])
15
+
16
+ let test3 _ = assert_equal [1;2;1] (lastVisitedIntegers [-1; -1; 3; 97; 3; 35; -1; 94; -1; 16; 58; -1; -1; -1; -1; 21; -1; -1; -1; -1; 97; -1; 94; 17; 94; 68; -1; 12; 35; 96; -1])
17
+
18
+ let test4 _ = assert_equal [1;2;1] (lastVisitedIntegers [-1; -1; 91; -1; 9; 54; -1; -1; 44; 13; 87; -1; 2; -1; -1; 40; -1; -1; 84; 36; -1; -1])
19
+
20
+ let test5 _ = assert_equal [1;2;1] (lastVisitedIntegers [-1; 48; -1; 95; 86; -1; 52; 78; 84; -1; -1; -1; 90; -1; 23; -1; -1; 70; -1; 23; -1; -1; 60; -1; 13; -1; -1; -1; 14; 40; -1; 95; -1; 46; 53; -1; 61; 12; 95; -1; 48; 99; 89; -1; 49; 26; 55; -1; -1; 58; 17; 53; -1; -1; 34; -1; -1; 19; 98; -1; -1; -1; -1; -1; 82; 93; 70; -1; -1; 63; 59; -1; 59; 68; -1; -1; 48; 66; -1; -1; 11; -1; 42; -1; 10; -1; 21; -1; -1; 61; -1; -1; 96])
21
+
22
+ let test6 _ = assert_equal [1;2;1] (lastVisitedIntegers [9; -1; -1; -1; 86; 66; -1; -1; -1; 17; 16; -1; -1; -1; -1; -1; 25; -1; -1; 75; -1; -1; 40; 55; 98; -1; 15])
23
+
24
+ let test7 _ = assert_equal [1;2;1] (lastVisitedIntegers [32; -1; 81; 45; -1; 70; -1; -1; 27; 2; 39; -1; -1; 44; 18; 50; -1; -1; 55; 31; 72; -1; 14; 86; 18; 54; 100; -1; 19; 95; 5; 44; -1; 16; 89; -1; 35; -1; 75; 6; -1; -1; 10; 94; -1; 72; -1; 59; 89; 90; 51; 34; 58; 7; -1; -1; -1; 93; 50; 55])
25
+
26
+ let test8 _ = assert_equal [1;2;1] (lastVisitedIntegers [-1; -1; 11; -1; 6; -1; -1; 22; 26; -1; -1; 92; 62; -1; -1; 5; 90; 76; -1; -1; -1; 43; 85; -1; 89; -1; -1; -1; -1; -1; -1; 15; 47; 6; -1; -1; -1; 34; -1; -1; 80; 49; -1; 36; 84; -1; 87; 53; -1; -1; -1; 39; 20; 71; 52; 16; 43; 91; -1; -1; 99; 22; -1; 84; 95; -1; -1; -1; -1; 42; -1; -1; 23; 81; 29; -1; 45; -1; 36; -1; 13; 42; -1; 77; 71; 75; 71; -1; -1; 15; -1; 43; 19; 16; 40; -1; -1; 55; -1])
27
+
28
+ let test9 _ = assert_equal [1;2;1] (lastVisitedIntegers [-1; -1; 96; 41; -1; 68; 9; 89; 2; -1; -1; 9; -1; -1; 31; -1; -1; 90; 81; -1; -1; -1; 43; 85; -1; -1; -1; -1; -1; 77; -1; -1; -1; -1; 59; 52; 86; -1; -1; -1; 28; 23; -1; -1; 46; 55; -1; -1; 69; 23; -1; -1; -1; -1; 42; -1; -1; 38; 52; -1; 57])
29
+
30
+ let test10 _ = assert_equal [1;2;1] (lastVisitedIntegers [39; -1; 1; 13; 23; 47; 21; -1; 3; 68; 51; 95; -1; -1; 40; -1; 18; 38; -1; 96; 3; -1; -1; -1; -1; 85; -1; 96; 95; 77; -1; -1; 35; -1; -1; 81; -1; -1; -1; -1; 8; 34; 86; -1; -1; -1; -1; 4; -1; -1; 4; 3; -1; -1; 100; 11; 4; -1; -1; 55; 70; -1; 90; 69; -1; -1; -1; -1; 34; -1; -1; 2; 94; 45; -1; -1; 2; -1; 49; -1; -1; -1; 9])
31
+
32
+
33
+ (* Grouping test cases *)
34
+ let suite = "Test Suite for lastVisitedIntegers" >::: [
35
+
36
+ "test1" >:: test1;
37
+ "test2" >:: test2;
38
+ "test3" >:: test3;
39
+ "test4" >:: test4;
40
+ "test5" >:: test5;
41
+ "test6" >:: test6;
42
+ "test7" >:: test7;
43
+ "test8" >:: test8;
44
+ "test9" >:: test9;
45
+ "test10" >:: test10;
46
+ ]
47
+
48
+
49
+ (* Running the tests *)
50
+ let () = run_test_tt_main suite
51
+ end
last_visited_integers/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.lastVisitedIntegers(List(1,2,-1,-1,-1)), List(2,1,-1))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.lastVisitedIntegers(List(1,-1,2,-1,-1)), List(1,2,1))
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.lastVisitedIntegers(-1,-1,3,97,3,35,-1,94,-1,16,58,-1,-1,-1,-1,21,-1,-1,-1,-1,97,-1,94,17,94,68,-1,12,35,96,-1), List())
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.lastVisitedIntegers(-1,-1,91,-1,9,54,-1,-1,44,13,87,-1,2,-1,-1,40,-1,-1,84,36,-1,-1), List())
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.lastVisitedIntegers(-1,48,-1,95,86,-1,52,78,84,-1,-1,-1,90,-1,23,-1,-1,70,-1,23,-1,-1,60,-1,13,-1,-1,-1,14,40,-1,95,-1,46,53,-1,61,12,95,-1,48,99,89,-1,49,26,55,-1,-1,58,17,53,-1,-1,34,-1,-1,19,98,-1,-1,-1,-1,-1,82,93,70,-1,-1,63,59,-1,59,68,-1,-1,48,66,-1,-1,11,-1,42,-1,10,-1,21,-1,-1,61,-1,-1,96), List())
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.lastVisitedIntegers(9,-1,-1,-1,86,66,-1,-1,-1,17,16,-1,-1,-1,-1,-1,25,-1,-1,75,-1,-1,40,55,98,-1,15), List())
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.lastVisitedIntegers(32,-1,81,45,-1,70,-1,-1,27,2,39,-1,-1,44,18,50,-1,-1,55,31,72,-1,14,86,18,54,100,-1,19,95,5,44,-1,16,89,-1,35,-1,75,6,-1,-1,10,94,-1,72,-1,59,89,90,51,34,58,7,-1,-1,-1,93,50,55), List())
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.lastVisitedIntegers(-1,-1,11,-1,6,-1,-1,22,26,-1,-1,92,62,-1,-1,5,90,76,-1,-1,-1,43,85,-1,89,-1,-1,-1,-1,-1,-1,15,47,6,-1,-1,-1,34,-1,-1,80,49,-1,36,84,-1,87,53,-1,-1,-1,39,20,71,52,16,43,91,-1,-1,99,22,-1,84,95,-1,-1,-1,-1,42,-1,-1,23,81,29,-1,45,-1,36,-1,13,42,-1,77,71,75,71,-1,-1,15,-1,43,19,16,40,-1,-1,55,-1), List())
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.lastVisitedIntegers(-1,-1,96,41,-1,68,9,89,2,-1,-1,9,-1,-1,31,-1,-1,90,81,-1,-1,-1,43,85,-1,-1,-1,-1,-1,77,-1,-1,-1,-1,59,52,86,-1,-1,-1,28,23,-1,-1,46,55,-1,-1,69,23,-1,-1,-1,-1,42,-1,-1,38,52,-1,57), List())
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.lastVisitedIntegers(39,-1,1,13,23,47,21,-1,3,68,51,95,-1,-1,40,-1,18,38,-1,96,3,-1,-1,-1,-1,85,-1,96,95,77,-1,-1,35,-1,-1,81,-1,-1,-1,-1,8,34,86,-1,-1,-1,-1,4,-1,-1,4,3,-1,-1,100,11,4,-1,-1,55,70,-1,90,69,-1,-1,-1,-1,34,-1,-1,2,94,45,-1,-1,2,-1,49,-1,-1,-1,9), List())
42
+ }
43
+
44
+ }
latest_time_you_can_obtain_after_replacing_characters/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ findLatestTime :: String -> String
7
+ findLatestTime s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (findLatestTime \"1?:?4 \")," "11:54" (findLatestTime "1?:?4"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (findLatestTime \"0?:5? \")," "09:59" (findLatestTime "0?:5?"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (findLatestTime \" 0 0 : 5 6 \")," "00:56" (findLatestTime " 0 0 : 5 6 "))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (findLatestTime \" 0 5 : 5 5 \")," "05:55" (findLatestTime " 0 5 : 5 5 "))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (findLatestTime \" 1 0 : 5 1 \")," "10:51" (findLatestTime " 1 0 : 5 1 "))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (findLatestTime \" 1 0 : 5 7 \")," "10:57" (findLatestTime " 1 0 : 5 7 "))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (findLatestTime \" 0 3 : 5 7 \")," "03:57" (findLatestTime " 0 3 : 5 7 "))
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
latest_time_you_can_obtain_after_replacing_characters/java_tests/Main.java ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals("1?:?4", findLatestTime("1?:?4"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("0?:5?", findLatestTime("0?:5?"));
18
+ }
19
+
20
+ }
latest_time_you_can_obtain_after_replacing_characters/meta.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3361,
3
+ "name": "latest_time_you_can_obtain_after_replacing_characters",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/",
6
+ "date": "2024-04-07 00:00:00",
7
+ "task_description": "You are given a string `s` representing a 12-hour format time where some of the digits (possibly none) are replaced with a `\"?\"`. 12-hour times are formatted as `\"HH:MM\"`, where `HH` is between `00` and `11`, and `MM` is between `00` and `59`. The earliest 12-hour time is `00:00`, and the latest is `11:59`. You have to replace **all** the `\"?\"` characters in `s` with digits such that the time we obtain by the resulting string is a **valid** 12-hour format time and is the **latest** possible. Return _the resulting string_. **Example 1:** **Input:** s = \"1?:?4\" **Output:** \"11:54\" **Explanation:** The latest 12-hour format time we can achieve by replacing `\"?\"` characters is `\"11:54\"`. **Example 2:** **Input:** s = \"0?:5?\" **Output:** \"09:59\" **Explanation:** The latest 12-hour format time we can achieve by replacing `\"?\"` characters is `\"09:59\"`. **Constraints:** `s.length == 5` `s[2]` is equal to the character `\":\"`. All characters except `s[2]` are digits or `\"?\"` characters. The input is generated such that there is **at least** one time between `\"00:00\"` and `\"11:59\"` that you can obtain after replacing the `\"?\"` characters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"1?:?4\"",
12
+ "output": "\"11:54\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"0?:5?\"",
17
+ "output": "\"09:59\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "00:56",
23
+ "output": "00:56"
24
+ },
25
+ {
26
+ "input": "05:55",
27
+ "output": "05:55"
28
+ },
29
+ {
30
+ "input": "10:51",
31
+ "output": "10:51"
32
+ },
33
+ {
34
+ "input": "10:57",
35
+ "output": "10:57"
36
+ },
37
+ {
38
+ "input": "03:57",
39
+ "output": "03:57"
40
+ }
41
+ ],
42
+ "haskell_template": "findLatestTime :: String -> String\nfindLatestTime s ",
43
+ "ocaml_template": "let findLatestTime (s: string) : string = ",
44
+ "scala_template": "def findLatestTime(s: String): String = { \n \n}",
45
+ "java_template": "class Solution {\n public String findLatestTime(String s) {\n \n }\n}",
46
+ "python_template": "class Solution(object):\n def findLatestTime(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
47
+ }
latest_time_you_can_obtain_after_replacing_characters/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let findLatestTime (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "11:54" (findLatestTime "1?:?4")
13
+
14
+ let test2 _ = assert_equal "09:59" (findLatestTime "0?:5?")
15
+
16
+ let test3 _ = assert_equal "09:59" (findLatestTime " 0 0 : 5 6 ")
17
+
18
+ let test4 _ = assert_equal "09:59" (findLatestTime " 0 5 : 5 5 ")
19
+
20
+ let test5 _ = assert_equal "09:59" (findLatestTime " 1 0 : 5 1 ")
21
+
22
+ let test6 _ = assert_equal "09:59" (findLatestTime " 1 0 : 5 7 ")
23
+
24
+ let test7 _ = assert_equal "09:59" (findLatestTime " 0 3 : 5 7 ")
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for findLatestTime" >::: [
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
latest_time_you_can_obtain_after_replacing_characters/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.findLatestTime("1?:?4"), "11:54")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.findLatestTime("0?:5?"), "09:59")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.findLatestTime(",0,0,:,5,6,"), "00:56")
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.findLatestTime(",0,5,:,5,5,"), "05:55")
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.findLatestTime(",1,0,:,5,1,"), "10:51")
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.findLatestTime(",1,0,:,5,7,"), "10:57")
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.findLatestTime(",0,3,:,5,7,"), "03:57")
30
+ }
31
+
32
+ }
left_and_right_sum_differences/.DS_Store ADDED
Binary file (6.15 kB). View file
 
left_and_right_sum_differences/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 (leftRightDifference [10,4,8,3])," [15,1,11,22] (leftRightDifference [10,4,8,3]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (leftRightDifference [1])," [0] (leftRightDifference [1]))
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
left_and_right_sum_differences/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(15,1,11,22)), leftRightDifference(new ArrayList<>(Arrays.asList(10,4,8,3))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0)), leftRightDifference(new ArrayList<>(Arrays.asList(1))));
19
+ }
20
+
21
+ }
left_and_right_sum_differences/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
left_and_right_sum_differences/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 [15;1;11;22] (leftRightDifference [10;4;8;3])
12
+
13
+ let test2 _ = assert_equal [0] (leftRightDifference [1])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for leftRightDifference" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
left_and_right_sum_differences/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.leftRightDifference(List(10,4,8,3)), List(15,1,11,22))
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.leftRightDifference(List(1)), List(0))
10
+ }
11
+
12
+ }
length_of_longest_subarray_with_at_most_k_frequency/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_subarray_with_at_most_k_frequency/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, maxSubarrayLength(new ArrayList<>(Arrays.asList(1,2,3,1,2,3,1,2)), 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, maxSubarrayLength(new ArrayList<>(Arrays.asList(1,2,1,2,1,2,1,2)), 1));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(4, maxSubarrayLength(new ArrayList<>(Arrays.asList(5,5,5,5,5,5,5)), 4));
23
+ }
24
+
25
+ }
length_of_longest_subarray_with_at_most_k_frequency/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8ffa20cd74c27ba3e720bdf9b7bd286ef480ae58b8de72de0b4d688f995d65f
3
+ size 16757474
length_of_longest_subarray_with_at_most_k_frequency/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_subarray_with_at_most_k_frequency/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_v_shaped_diagonal_segment/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_v_shaped_diagonal_segment/java_tests/Main.java ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(5, lenOfVDiagonal(Arrays.asList(Arrays.asList(2,2,1,2,2),Arrays.asList(2,0,2,2,0),Arrays.asList(2,0,1,1,0),Arrays.asList(1,0,2,2,2),Arrays.asList(2,0,0,2,2))));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(4, lenOfVDiagonal(Arrays.asList(Arrays.asList(2,2,2,2,2),Arrays.asList(2,0,2,2,0),Arrays.asList(2,0,1,1,0),Arrays.asList(1,0,2,2,2),Arrays.asList(2,0,0,2,2))));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(5, lenOfVDiagonal(Arrays.asList(Arrays.asList(1,2,2,2,2),Arrays.asList(2,2,2,2,0),Arrays.asList(2,0,0,0,0),Arrays.asList(0,0,2,2,2),Arrays.asList(2,0,0,2,0))));
22
+ }
23
+ @Test
24
+ public void test4() {
25
+ assertEquals(1, lenOfVDiagonal(Arrays.asList(Arrays.asList(1))));
26
+ }
27
+
28
+ }
length_of_longest_v_shaped_diagonal_segment/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_v_shaped_diagonal_segment/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
length_of_longest_v_shaped_diagonal_segment/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_alphabetical_continuous_substring/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_alphabetical_continuous_substring/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, longestContinuousSubstring("abacaba"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(5, longestContinuousSubstring("abcde"));
18
+ }
19
+
20
+ }
length_of_the_longest_alphabetical_continuous_substring/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_alphabetical_continuous_substring/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_alphabetical_continuous_substring/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_increasing_path/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f5e93b445a0e44d470e77d524a1817c55e372aa3c4ec9f56ddf155e53377e31
3
+ size 16909194
length_of_the_longest_increasing_path/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, maxPathLength(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(3,1)),new ArrayList<>(Arrays.asList(2,2)),new ArrayList<>(Arrays.asList(4,1)),new ArrayList<>(Arrays.asList(0,0)),new ArrayList<>(Arrays.asList(5,3)))), 1));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(2, maxPathLength(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,1)),new ArrayList<>(Arrays.asList(7,0)),new ArrayList<>(Arrays.asList(5,6)))), 2));
19
+ }
20
+
21
+ }
length_of_the_longest_increasing_path/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b4f6883174401db3434c70e826d663a5522a217d13c23d04fc39f37e8edb591
3
+ size 40454851
length_of_the_longest_increasing_path/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_increasing_path/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_subsequence_that_sums_to_target/haskell_tests/Main.hs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (lengthOfLongestSubsequence [1,2,3,4,5] 9)," 3 (lengthOfLongestSubsequence [1,2,3,4,5] 9))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (lengthOfLongestSubsequence [4,1,3,2,1,5] 7)," 4 (lengthOfLongestSubsequence [4,1,3,2,1,5] 7))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (lengthOfLongestSubsequence [1,1,5,4,5] 3)," (-1) (lengthOfLongestSubsequence [1,1,5,4,5] 3))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (lengthOfLongestSubsequence [531, 193, 87, 198, 366, 469, 928, 314, 99, 217, 198, 228, 593, 695, 958, 189, 751, 290, 717, 696, 566, 469, 795, 810, 984, 36, 10, 629, 141, 161, 936, 741, 295, 146, 855, 543, 694, 643, 408, 476, 769, 558, 639, 446, 114, 123, 263, 839, 482, 289, 848, 706, 212, 758, 4, 261, 665, 873, 898, 392, 448, 649, 306, 564, 256, 882, 560, 165, 768, 123, 521, 492, 786, 831, 183, 189, 337, 942, 469, 295, 299, 712, 808, 196, 115, 844, 608, 171, 206, 610, 270, 107, 528, 675, 581, 228, 326, 713, 708, 928, 720, 586, 840, 720, 559, 517, 922, 45, 342, 975, 620, 590, 929, 796, 581, 960, 802, 229, 698, 866, 611, 155, 770, 660, 53, 400, 965, 291, 905, 320, 720, 218, 641, 850, 245, 112, 75, 202, 688, 642, 421, 851, 412, 671, 518, 916, 676, 186, 960, 184, 877, 898, 343, 703, 87, 894, 240, 321, 960, 901, 110, 745, 672, 665, 750, 487, 707, 914, 956, 265, 719, 611, 556, 825, 301, 70, 763, 405, 878, 189, 118, 6, 603, 239, 334, 732, 498, 814, 859, 865, 79, 83, 480, 445, 62, 688, 527, 722, 66, 69, 78, 837, 50, 617, 458, 784, 479, 914, 50, 923, 782, 345, 712, 80, 22, 367, 867, 774, 122, 255, 477, 922, 931, 688, 855, 213, 311, 854, 786, 340, 876, 636, 714, 104, 891, 407, 611, 115, 833, 950, 194, 60, 350, 137, 480, 980, 175, 861, 301, 170, 162, 560, 224, 430, 427, 395, 569, 871, 942, 707, 788, 295, 99, 180, 121, 775, 651, 865, 597, 938, 385, 798, 796, 101, 143, 51, 845, 294, 785, 894, 646, 172, 698, 342, 260, 615, 254, 571, 607, 639, 833, 829, 480, 507, 924, 886, 954, 271, 177, 154, 342, 101, 258, 521, 274, 175, 475, 639, 569, 981, 542, 636, 781, 520, 801, 453, 506, 986, 832, 550, 476, 814, 54, 207, 73, 229, 909, 302, 333, 25, 752, 155, 931, 154, 39, 194, 713, 872, 241, 546, 321, 440, 882, 50, 131, 272, 105, 509, 455, 649, 178, 225, 637, 744, 766, 374, 421, 213, 175, 474, 546, 97, 104, 613, 944, 997, 881, 611, 987, 594, 388, 698, 952, 981, 772, 79, 89, 433, 191, 574, 161, 630, 586, 767, 945, 227, 660, 397, 161, 76, 759, 552, 560, 830, 101, 642, 745, 740, 591, 272, 435, 437, 747, 753, 719, 486, 343, 140, 968, 308, 450, 187, 129, 608, 613, 241, 634, 321, 418, 516, 994, 330, 318, 920, 859, 705, 646, 156, 907, 711, 300, 544, 363, 123, 162, 88, 577, 931, 737, 477, 307, 111, 42, 978, 380, 49, 548, 693, 615, 159, 712, 747, 67, 132, 67, 806, 19, 887, 962, 247, 757, 809, 380, 126, 673, 367, 727, 214, 223, 630, 322, 641, 757, 200, 406, 30, 44, 534, 63, 30, 615, 914, 499, 59, 972, 68, 665, 154, 183, 884, 551, 412, 866, 753, 105, 159, 577, 763, 228, 540, 331, 764, 846, 304, 31, 306, 846, 202, 798, 15, 848, 40, 66, 244, 170, 567, 658, 800, 515, 832, 151, 459, 399, 871, 449, 945, 706, 482, 695, 932, 347, 87, 398, 8, 8, 170, 73, 937, 660, 98, 127, 791, 826, 657, 21, 664, 936, 278, 715, 665, 890, 546, 206, 697, 166, 873, 436, 845, 243, 991, 43, 803, 404, 871, 477, 618, 88, 786, 343, 422, 53, 725, 120, 959, 755, 741, 914, 906, 606, 742, 580, 439, 823, 507, 775, 505, 128, 134, 563, 885, 922, 995, 242, 778, 125, 569, 972, 481, 693, 978, 538, 134, 907, 29, 92, 172, 978, 555, 85, 670, 312, 891, 780, 810, 813, 3, 484, 620, 327, 590, 459, 581, 34, 608, 328, 965, 43, 867, 788, 299, 358, 966, 709, 563, 697, 15, 383, 552, 857, 667, 416, 911, 765, 535, 85, 113, 986, 526, 518, 474, 243, 265, 358, 541, 839, 214, 95, 399, 809, 234, 674, 434, 523, 200, 606, 696, 536, 943, 990, 320, 928, 724, 549, 789, 132, 774, 582, 23, 538, 839, 323, 306, 217, 866, 935, 320, 850, 98, 360, 702, 427, 31, 271, 691, 737, 549, 742, 43, 846, 8, 950, 446, 188, 846, 661, 653, 590, 8, 52, 148, 572, 281, 355, 958, 350, 131, 745, 870, 99, 956, 471, 792, 499, 134, 231, 606, 942, 817, 27, 7, 288, 453, 327, 281, 357, 541, 920, 152, 413, 218, 771, 786, 440, 19, 124, 713, 798, 296, 492, 280, 119, 91, 969, 517, 164, 623, 351, 398, 801, 264, 206, 806, 500, 884, 919, 950, 677, 508, 504, 36, 972, 884, 185, 86, 182, 58, 994, 4, 854, 321, 205, 12, 495, 20, 66, 551, 93, 417, 885, 643, 882, 995, 244, 414, 379, 344, 588, 85, 37, 430, 582, 212, 109, 790, 159, 276, 366, 644, 297, 928, 584, 510, 259, 180, 357, 859, 737, 843, 2, 205, 683, 428, 250, 939, 778, 945, 669, 25, 911, 250, 129, 972, 856, 53, 31, 111, 378, 328, 756, 149, 250, 719, 700, 578, 22, 48, 266, 634, 732, 214, 361, 979, 229, 691, 279, 112, 405, 544, 815, 828, 97, 217, 61, 286, 813, 2, 102, 882, 473, 255, 81, 1000, 466, 450, 209] 767)," 37 (lengthOfLongestSubsequence [531, 193, 87, 198, 366, 469, 928, 314, 99, 217, 198, 228, 593, 695, 958, 189, 751, 290, 717, 696, 566, 469, 795, 810, 984, 36, 10, 629, 141, 161, 936, 741, 295, 146, 855, 543, 694, 643, 408, 476, 769, 558, 639, 446, 114, 123, 263, 839, 482, 289, 848, 706, 212, 758, 4, 261, 665, 873, 898, 392, 448, 649, 306, 564, 256, 882, 560, 165, 768, 123, 521, 492, 786, 831, 183, 189, 337, 942, 469, 295, 299, 712, 808, 196, 115, 844, 608, 171, 206, 610, 270, 107, 528, 675, 581, 228, 326, 713, 708, 928, 720, 586, 840, 720, 559, 517, 922, 45, 342, 975, 620, 590, 929, 796, 581, 960, 802, 229, 698, 866, 611, 155, 770, 660, 53, 400, 965, 291, 905, 320, 720, 218, 641, 850, 245, 112, 75, 202, 688, 642, 421, 851, 412, 671, 518, 916, 676, 186, 960, 184, 877, 898, 343, 703, 87, 894, 240, 321, 960, 901, 110, 745, 672, 665, 750, 487, 707, 914, 956, 265, 719, 611, 556, 825, 301, 70, 763, 405, 878, 189, 118, 6, 603, 239, 334, 732, 498, 814, 859, 865, 79, 83, 480, 445, 62, 688, 527, 722, 66, 69, 78, 837, 50, 617, 458, 784, 479, 914, 50, 923, 782, 345, 712, 80, 22, 367, 867, 774, 122, 255, 477, 922, 931, 688, 855, 213, 311, 854, 786, 340, 876, 636, 714, 104, 891, 407, 611, 115, 833, 950, 194, 60, 350, 137, 480, 980, 175, 861, 301, 170, 162, 560, 224, 430, 427, 395, 569, 871, 942, 707, 788, 295, 99, 180, 121, 775, 651, 865, 597, 938, 385, 798, 796, 101, 143, 51, 845, 294, 785, 894, 646, 172, 698, 342, 260, 615, 254, 571, 607, 639, 833, 829, 480, 507, 924, 886, 954, 271, 177, 154, 342, 101, 258, 521, 274, 175, 475, 639, 569, 981, 542, 636, 781, 520, 801, 453, 506, 986, 832, 550, 476, 814, 54, 207, 73, 229, 909, 302, 333, 25, 752, 155, 931, 154, 39, 194, 713, 872, 241, 546, 321, 440, 882, 50, 131, 272, 105, 509, 455, 649, 178, 225, 637, 744, 766, 374, 421, 213, 175, 474, 546, 97, 104, 613, 944, 997, 881, 611, 987, 594, 388, 698, 952, 981, 772, 79, 89, 433, 191, 574, 161, 630, 586, 767, 945, 227, 660, 397, 161, 76, 759, 552, 560, 830, 101, 642, 745, 740, 591, 272, 435, 437, 747, 753, 719, 486, 343, 140, 968, 308, 450, 187, 129, 608, 613, 241, 634, 321, 418, 516, 994, 330, 318, 920, 859, 705, 646, 156, 907, 711, 300, 544, 363, 123, 162, 88, 577, 931, 737, 477, 307, 111, 42, 978, 380, 49, 548, 693, 615, 159, 712, 747, 67, 132, 67, 806, 19, 887, 962, 247, 757, 809, 380, 126, 673, 367, 727, 214, 223, 630, 322, 641, 757, 200, 406, 30, 44, 534, 63, 30, 615, 914, 499, 59, 972, 68, 665, 154, 183, 884, 551, 412, 866, 753, 105, 159, 577, 763, 228, 540, 331, 764, 846, 304, 31, 306, 846, 202, 798, 15, 848, 40, 66, 244, 170, 567, 658, 800, 515, 832, 151, 459, 399, 871, 449, 945, 706, 482, 695, 932, 347, 87, 398, 8, 8, 170, 73, 937, 660, 98, 127, 791, 826, 657, 21, 664, 936, 278, 715, 665, 890, 546, 206, 697, 166, 873, 436, 845, 243, 991, 43, 803, 404, 871, 477, 618, 88, 786, 343, 422, 53, 725, 120, 959, 755, 741, 914, 906, 606, 742, 580, 439, 823, 507, 775, 505, 128, 134, 563, 885, 922, 995, 242, 778, 125, 569, 972, 481, 693, 978, 538, 134, 907, 29, 92, 172, 978, 555, 85, 670, 312, 891, 780, 810, 813, 3, 484, 620, 327, 590, 459, 581, 34, 608, 328, 965, 43, 867, 788, 299, 358, 966, 709, 563, 697, 15, 383, 552, 857, 667, 416, 911, 765, 535, 85, 113, 986, 526, 518, 474, 243, 265, 358, 541, 839, 214, 95, 399, 809, 234, 674, 434, 523, 200, 606, 696, 536, 943, 990, 320, 928, 724, 549, 789, 132, 774, 582, 23, 538, 839, 323, 306, 217, 866, 935, 320, 850, 98, 360, 702, 427, 31, 271, 691, 737, 549, 742, 43, 846, 8, 950, 446, 188, 846, 661, 653, 590, 8, 52, 148, 572, 281, 355, 958, 350, 131, 745, 870, 99, 956, 471, 792, 499, 134, 231, 606, 942, 817, 27, 7, 288, 453, 327, 281, 357, 541, 920, 152, 413, 218, 771, 786, 440, 19, 124, 713, 798, 296, 492, 280, 119, 91, 969, 517, 164, 623, 351, 398, 801, 264, 206, 806, 500, 884, 919, 950, 677, 508, 504, 36, 972, 884, 185, 86, 182, 58, 994, 4, 854, 321, 205, 12, 495, 20, 66, 551, 93, 417, 885, 643, 882, 995, 244, 414, 379, 344, 588, 85, 37, 430, 582, 212, 109, 790, 159, 276, 366, 644, 297, 928, 584, 510, 259, 180, 357, 859, 737, 843, 2, 205, 683, 428, 250, 939, 778, 945, 669, 25, 911, 250, 129, 972, 856, 53, 31, 111, 378, 328, 756, 149, 250, 719, 700, 578, 22, 48, 266, 634, 732, 214, 361, 979, 229, 691, 279, 112, 405, 544, 815, 828, 97, 217, 61, 286, 813, 2, 102, 882, 473, 255, 81, 1000, 466, 450, 209] 767))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (lengthOfLongestSubsequence [297, 353, 392, 129, 520, 66, 999, 72, 771, 595, 709, 573, 12, 307, 40, 933, 26, 485, 862, 93, 601, 615, 796, 368, 654, 518, 396, 426, 624, 541, 58, 915, 950, 753, 489, 381, 447, 793, 369, 108, 805, 509, 382, 525, 142, 38, 110, 284, 49, 512, 56, 307, 806, 842, 580, 881, 379, 127, 409, 445, 222, 936, 257, 523, 718, 818, 581, 908, 569, 347, 221, 919, 308, 70, 900, 310, 851, 818, 740, 368, 908, 118, 258, 171, 582, 104, 453, 782, 451, 690, 135, 579, 907, 4, 502, 954, 747, 654, 415, 522, 5, 78, 447, 641, 492, 453, 608, 744, 971, 337, 889, 415, 927, 350, 451, 229, 176, 241, 371, 864, 221, 110, 83, 103, 160, 502, 259, 74, 90, 821, 431, 370, 74, 140, 525, 585, 637, 530, 141, 744, 701, 414, 146, 970, 705, 549, 496, 731, 189, 907, 29, 593, 159, 974, 524, 643, 39, 737, 729, 192, 215, 444, 174, 799, 988, 723, 827, 333, 591, 173, 668, 17, 513, 260, 318, 453, 38, 360, 226, 664, 107, 985, 906, 726, 302, 806, 292, 982, 580, 684, 154, 547, 233, 509, 790, 478, 619, 306, 998, 476, 928, 450, 841, 409, 564, 841, 97, 807, 700, 977, 373, 695, 626, 178, 380, 657, 497, 188, 668, 132, 297, 20, 651, 905, 993, 749, 944, 280, 314, 69, 83, 220, 220, 348, 895, 811, 824, 911, 261, 153, 598, 611, 605, 825, 773, 43, 651, 31, 387, 989, 321, 821, 933, 574, 266, 909, 165, 935, 112, 712, 170, 699, 48, 694, 619, 968, 930, 265, 680, 365, 216, 701, 781, 421, 966, 835, 518, 484, 251, 431, 630, 872, 724, 251, 213, 660, 603, 760, 100, 771, 580, 592, 206, 579, 769, 19, 343, 933, 453, 184] 887)," 22 (lengthOfLongestSubsequence [297, 353, 392, 129, 520, 66, 999, 72, 771, 595, 709, 573, 12, 307, 40, 933, 26, 485, 862, 93, 601, 615, 796, 368, 654, 518, 396, 426, 624, 541, 58, 915, 950, 753, 489, 381, 447, 793, 369, 108, 805, 509, 382, 525, 142, 38, 110, 284, 49, 512, 56, 307, 806, 842, 580, 881, 379, 127, 409, 445, 222, 936, 257, 523, 718, 818, 581, 908, 569, 347, 221, 919, 308, 70, 900, 310, 851, 818, 740, 368, 908, 118, 258, 171, 582, 104, 453, 782, 451, 690, 135, 579, 907, 4, 502, 954, 747, 654, 415, 522, 5, 78, 447, 641, 492, 453, 608, 744, 971, 337, 889, 415, 927, 350, 451, 229, 176, 241, 371, 864, 221, 110, 83, 103, 160, 502, 259, 74, 90, 821, 431, 370, 74, 140, 525, 585, 637, 530, 141, 744, 701, 414, 146, 970, 705, 549, 496, 731, 189, 907, 29, 593, 159, 974, 524, 643, 39, 737, 729, 192, 215, 444, 174, 799, 988, 723, 827, 333, 591, 173, 668, 17, 513, 260, 318, 453, 38, 360, 226, 664, 107, 985, 906, 726, 302, 806, 292, 982, 580, 684, 154, 547, 233, 509, 790, 478, 619, 306, 998, 476, 928, 450, 841, 409, 564, 841, 97, 807, 700, 977, 373, 695, 626, 178, 380, 657, 497, 188, 668, 132, 297, 20, 651, 905, 993, 749, 944, 280, 314, 69, 83, 220, 220, 348, 895, 811, 824, 911, 261, 153, 598, 611, 605, 825, 773, 43, 651, 31, 387, 989, 321, 821, 933, 574, 266, 909, 165, 935, 112, 712, 170, 699, 48, 694, 619, 968, 930, 265, 680, 365, 216, 701, 781, 421, 966, 835, 518, 484, 251, 431, 630, 872, 724, 251, 213, 660, 603, 760, 100, 771, 580, 592, 206, 579, 769, 19, 343, 933, 453, 184] 887))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (lengthOfLongestSubsequence [712, 345, 180, 787, 698, 248, 871, 945, 614, 122, 72, 307, 573, 648, 260, 917, 442, 495, 332, 48, 313, 969, 66, 225, 469, 800, 549, 392, 651, 211, 111, 596, 332, 752, 311, 140, 322, 282, 174, 405, 527, 447, 953, 348, 230, 15, 367, 975, 733, 270, 749, 216, 30, 530, 392, 709, 958, 76, 604, 49, 934, 255, 184, 662, 63, 450, 402, 298, 418, 824, 234, 827, 898, 657, 748, 880, 831, 252, 751, 632, 324, 84, 570, 17, 360, 58, 56, 425, 424, 924, 970, 568, 112, 934, 32, 403, 642, 380, 229, 905, 903, 242, 170, 754, 709, 117, 38, 261, 684, 884, 38, 589, 394, 789, 629, 526, 835, 516, 452, 811, 550, 163, 526, 546, 887, 512, 532, 417, 946, 205, 714, 131, 390, 884, 864, 665, 404, 594, 816, 716, 217, 618, 986, 692, 983, 662, 239, 83, 706, 874, 318, 403, 851, 150, 540, 502, 569, 273, 177, 70, 652, 156, 789, 912, 3, 639, 803, 634, 691, 907, 717, 89, 806, 47, 432, 144, 451, 895, 784, 609, 916, 282, 775, 645, 498, 386, 252, 648, 920, 446, 349, 762, 760, 382, 791, 4, 193, 449, 953, 108, 300, 596, 464, 473, 27, 142, 847, 154, 565, 974, 782, 565, 914, 369, 800, 899, 21, 391, 815, 515, 890, 557, 636, 825, 391, 443, 415, 643, 229, 504, 680, 989, 737, 398, 666, 405, 921, 314, 855, 485, 163, 785, 483, 62, 599, 361, 630, 28, 742, 459, 382, 683, 989, 158, 116, 888, 339, 173, 855, 209, 456, 488, 590, 673, 173, 641, 31, 899, 718, 87, 786, 515, 208, 153, 833, 398, 855, 61, 16, 632, 847, 792, 469, 666, 868, 321, 818, 369, 683, 384, 549, 827, 490, 503, 786, 117, 833, 398, 298, 636, 757, 169, 442, 867, 633, 283, 796, 79, 540, 56, 133, 826, 163, 1, 422, 203, 221, 976, 849, 962, 284, 331, 203, 886, 263, 388, 446, 416, 166, 240, 650, 440, 829, 862, 172, 895, 164, 811, 944, 773, 328, 574, 91, 449, 841, 851, 579, 223, 126, 822, 903, 938, 381, 696, 946, 668, 443, 993, 117, 694, 693, 447, 98, 57, 280, 159, 63, 474, 746, 980, 629, 589, 311, 392, 4, 585, 788, 7, 46, 453, 125, 9, 367, 293, 846, 720, 609, 129, 563, 650, 459, 283, 239, 391, 881, 520, 97, 332, 29, 915, 489, 985, 406, 53, 578, 674, 612, 34, 428, 860, 610, 360, 517, 951, 509, 571, 899, 163, 256, 237, 411, 103, 539, 566, 808, 965, 837, 403, 684, 929, 118, 708, 826, 647, 720, 402, 797, 260, 921, 914, 127, 258, 314, 870, 908, 215, 765, 176, 719, 497, 105, 130, 203, 583, 858, 696, 956, 819, 852, 96, 514, 939, 694, 446, 269, 327, 793, 892, 773, 873, 457, 336, 297, 177, 730, 354, 767, 642, 93, 724, 734, 588, 928, 87, 473, 210, 208, 405, 650, 723, 802, 123, 337, 400, 509, 781, 839, 507, 286, 38, 133, 984, 247, 949, 251, 227, 538, 662, 685, 371, 199, 448, 688, 102, 156, 447, 144, 924, 782, 43, 402, 418, 704, 677, 925, 1000, 907, 940, 111, 551, 932, 412, 153, 103, 903, 605, 44, 141, 80, 537, 729, 399, 811, 495, 609, 409, 901, 233, 432, 279, 17, 87, 13, 759, 887, 602, 428, 400, 757, 799, 49, 840, 357, 507, 434, 755, 350, 454, 943, 517, 427, 65, 183, 891, 195, 915, 250, 428, 808, 257, 939, 682, 993, 890, 938, 653, 665, 204, 450, 127, 451, 788, 466, 567, 167, 169, 494, 124, 972, 631, 261, 529, 763, 743, 354, 445, 399, 860, 13, 653, 392, 406, 555, 25, 473, 530, 327, 365, 659, 906, 525, 789, 490, 506, 479, 547, 602, 923, 923, 923, 197, 73, 769, 523, 185, 420, 192, 831, 398, 234, 120, 229, 841, 77, 561, 103, 809, 222, 216, 941, 459, 110, 385, 968, 824, 812, 13, 246, 546, 738, 55, 3, 598, 739, 623, 178, 387, 613, 788, 372, 490, 593, 434, 522, 574, 878, 64, 739, 400, 437, 329, 262, 656, 324, 659, 276, 576, 229, 22, 861, 245, 736, 927, 887, 767, 388, 820, 872, 199, 731, 451, 296, 425, 482, 541, 524, 254, 659, 572, 190, 556, 764, 107, 464, 148, 56, 199, 295, 745, 398, 827, 905, 475, 430, 727, 280, 253, 404, 159, 770, 172, 888, 115, 295, 609, 400, 366, 122, 948, 455, 181, 868, 686, 493, 34, 921, 52, 462, 97, 12, 163, 512, 961, 482, 791, 863, 143, 528, 387, 412, 949, 16, 913, 726, 596, 332, 19, 887, 901, 707, 840, 842, 216, 893, 802, 401, 974, 576, 735, 626, 322, 595, 109, 919, 283, 507, 991, 987, 86, 145, 741, 856, 386, 292, 80, 161, 835, 845, 571, 69, 100, 530, 492, 945, 524, 706, 389, 110, 150, 384, 147, 570, 80, 290, 853, 992, 491, 826, 397, 803, 784, 176, 566, 474, 50, 830, 988, 632, 754, 193, 961, 663, 193, 257, 456, 114, 522, 177, 567, 701, 876, 439, 670, 808, 841, 661, 960, 564, 211, 874, 963, 791, 846, 308, 183, 719, 394, 815, 974, 296, 845, 301, 954, 795, 575, 736, 917, 201, 798, 930, 814, 313, 892, 714, 918, 314, 504, 828, 959, 534, 97, 886, 656, 609, 194, 731, 302, 692, 633, 716, 956, 556] 542)," 29 (lengthOfLongestSubsequence [712, 345, 180, 787, 698, 248, 871, 945, 614, 122, 72, 307, 573, 648, 260, 917, 442, 495, 332, 48, 313, 969, 66, 225, 469, 800, 549, 392, 651, 211, 111, 596, 332, 752, 311, 140, 322, 282, 174, 405, 527, 447, 953, 348, 230, 15, 367, 975, 733, 270, 749, 216, 30, 530, 392, 709, 958, 76, 604, 49, 934, 255, 184, 662, 63, 450, 402, 298, 418, 824, 234, 827, 898, 657, 748, 880, 831, 252, 751, 632, 324, 84, 570, 17, 360, 58, 56, 425, 424, 924, 970, 568, 112, 934, 32, 403, 642, 380, 229, 905, 903, 242, 170, 754, 709, 117, 38, 261, 684, 884, 38, 589, 394, 789, 629, 526, 835, 516, 452, 811, 550, 163, 526, 546, 887, 512, 532, 417, 946, 205, 714, 131, 390, 884, 864, 665, 404, 594, 816, 716, 217, 618, 986, 692, 983, 662, 239, 83, 706, 874, 318, 403, 851, 150, 540, 502, 569, 273, 177, 70, 652, 156, 789, 912, 3, 639, 803, 634, 691, 907, 717, 89, 806, 47, 432, 144, 451, 895, 784, 609, 916, 282, 775, 645, 498, 386, 252, 648, 920, 446, 349, 762, 760, 382, 791, 4, 193, 449, 953, 108, 300, 596, 464, 473, 27, 142, 847, 154, 565, 974, 782, 565, 914, 369, 800, 899, 21, 391, 815, 515, 890, 557, 636, 825, 391, 443, 415, 643, 229, 504, 680, 989, 737, 398, 666, 405, 921, 314, 855, 485, 163, 785, 483, 62, 599, 361, 630, 28, 742, 459, 382, 683, 989, 158, 116, 888, 339, 173, 855, 209, 456, 488, 590, 673, 173, 641, 31, 899, 718, 87, 786, 515, 208, 153, 833, 398, 855, 61, 16, 632, 847, 792, 469, 666, 868, 321, 818, 369, 683, 384, 549, 827, 490, 503, 786, 117, 833, 398, 298, 636, 757, 169, 442, 867, 633, 283, 796, 79, 540, 56, 133, 826, 163, 1, 422, 203, 221, 976, 849, 962, 284, 331, 203, 886, 263, 388, 446, 416, 166, 240, 650, 440, 829, 862, 172, 895, 164, 811, 944, 773, 328, 574, 91, 449, 841, 851, 579, 223, 126, 822, 903, 938, 381, 696, 946, 668, 443, 993, 117, 694, 693, 447, 98, 57, 280, 159, 63, 474, 746, 980, 629, 589, 311, 392, 4, 585, 788, 7, 46, 453, 125, 9, 367, 293, 846, 720, 609, 129, 563, 650, 459, 283, 239, 391, 881, 520, 97, 332, 29, 915, 489, 985, 406, 53, 578, 674, 612, 34, 428, 860, 610, 360, 517, 951, 509, 571, 899, 163, 256, 237, 411, 103, 539, 566, 808, 965, 837, 403, 684, 929, 118, 708, 826, 647, 720, 402, 797, 260, 921, 914, 127, 258, 314, 870, 908, 215, 765, 176, 719, 497, 105, 130, 203, 583, 858, 696, 956, 819, 852, 96, 514, 939, 694, 446, 269, 327, 793, 892, 773, 873, 457, 336, 297, 177, 730, 354, 767, 642, 93, 724, 734, 588, 928, 87, 473, 210, 208, 405, 650, 723, 802, 123, 337, 400, 509, 781, 839, 507, 286, 38, 133, 984, 247, 949, 251, 227, 538, 662, 685, 371, 199, 448, 688, 102, 156, 447, 144, 924, 782, 43, 402, 418, 704, 677, 925, 1000, 907, 940, 111, 551, 932, 412, 153, 103, 903, 605, 44, 141, 80, 537, 729, 399, 811, 495, 609, 409, 901, 233, 432, 279, 17, 87, 13, 759, 887, 602, 428, 400, 757, 799, 49, 840, 357, 507, 434, 755, 350, 454, 943, 517, 427, 65, 183, 891, 195, 915, 250, 428, 808, 257, 939, 682, 993, 890, 938, 653, 665, 204, 450, 127, 451, 788, 466, 567, 167, 169, 494, 124, 972, 631, 261, 529, 763, 743, 354, 445, 399, 860, 13, 653, 392, 406, 555, 25, 473, 530, 327, 365, 659, 906, 525, 789, 490, 506, 479, 547, 602, 923, 923, 923, 197, 73, 769, 523, 185, 420, 192, 831, 398, 234, 120, 229, 841, 77, 561, 103, 809, 222, 216, 941, 459, 110, 385, 968, 824, 812, 13, 246, 546, 738, 55, 3, 598, 739, 623, 178, 387, 613, 788, 372, 490, 593, 434, 522, 574, 878, 64, 739, 400, 437, 329, 262, 656, 324, 659, 276, 576, 229, 22, 861, 245, 736, 927, 887, 767, 388, 820, 872, 199, 731, 451, 296, 425, 482, 541, 524, 254, 659, 572, 190, 556, 764, 107, 464, 148, 56, 199, 295, 745, 398, 827, 905, 475, 430, 727, 280, 253, 404, 159, 770, 172, 888, 115, 295, 609, 400, 366, 122, 948, 455, 181, 868, 686, 493, 34, 921, 52, 462, 97, 12, 163, 512, 961, 482, 791, 863, 143, 528, 387, 412, 949, 16, 913, 726, 596, 332, 19, 887, 901, 707, 840, 842, 216, 893, 802, 401, 974, 576, 735, 626, 322, 595, 109, 919, 283, 507, 991, 987, 86, 145, 741, 856, 386, 292, 80, 161, 835, 845, 571, 69, 100, 530, 492, 945, 524, 706, 389, 110, 150, 384, 147, 570, 80, 290, 853, 992, 491, 826, 397, 803, 784, 176, 566, 474, 50, 830, 988, 632, 754, 193, 961, 663, 193, 257, 456, 114, 522, 177, 567, 701, 876, 439, 670, 808, 841, 661, 960, 564, 211, 874, 963, 791, 846, 308, 183, 719, 394, 815, 974, 296, 845, 301, 954, 795, 575, 736, 917, 201, 798, 930, 814, 313, 892, 714, 918, 314, 504, 828, 959, 534, 97, 886, 656, 609, 194, 731, 302, 692, 633, 716, 956, 556] 542))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (lengthOfLongestSubsequence [491, 307, 163, 565, 187, 374, 825, 118, 74, 279, 352, 225, 996, 514, 718, 832, 473, 527, 872, 91, 861, 597, 300, 445, 986, 698, 903, 781, 827, 939, 544, 893, 557, 105, 236, 364, 156, 448, 810, 224, 507, 746, 766, 26, 252, 849, 917, 448, 629, 816, 838, 223, 768, 936, 271, 406, 145, 578, 938, 34, 958, 807, 694, 905, 468, 185, 122, 621, 516, 87, 421, 416, 357, 499, 406, 664, 192, 821, 164, 136, 244, 571, 984, 415, 278, 204, 412, 647, 633, 982, 689, 900, 532, 162, 222, 739, 634, 625, 774, 557, 199, 473, 133, 817, 780, 407, 882, 579, 636, 329, 637, 298, 211, 83, 707, 701, 967, 456, 948, 362, 674, 747, 155, 84, 116, 752, 200, 777, 926, 94, 926, 11, 380, 463, 499, 436, 365, 268, 182, 36, 215, 491, 137, 175, 198, 458, 450, 772, 815, 664, 838, 3, 307, 306, 330, 902, 99, 954, 86, 506, 541, 97, 912, 876, 855, 612, 131, 844, 908, 466, 278, 731, 790, 927, 206, 98, 164, 806, 894, 420, 199, 127, 590, 467, 531, 771, 966, 596, 510, 341, 709, 4, 355, 363, 163, 746, 576, 781, 720, 56, 859, 314, 220, 879, 355, 786, 689, 433, 133, 95, 95, 147, 48, 665, 498, 204, 344, 261, 184, 26, 730, 626, 640, 166, 638, 429, 727, 734, 193, 69, 663, 673, 600, 907, 25, 21, 203, 223, 470, 337, 829, 66, 250, 610, 25, 269, 66, 864, 511, 341, 219, 606, 631, 17, 101, 804, 790, 968, 112, 215, 906, 585, 748, 594, 224, 574, 249, 80, 90, 335, 324, 4, 891, 852, 51, 952, 21, 555, 379, 698, 667, 881, 326, 732, 47, 867, 866, 349, 318, 363, 509, 23, 222, 158, 49, 937, 249, 929, 37, 91, 130, 467, 699, 61, 242, 414, 708, 130, 637, 812, 496, 369, 595, 457, 955, 134, 571, 85] 928)," 25 (lengthOfLongestSubsequence [491, 307, 163, 565, 187, 374, 825, 118, 74, 279, 352, 225, 996, 514, 718, 832, 473, 527, 872, 91, 861, 597, 300, 445, 986, 698, 903, 781, 827, 939, 544, 893, 557, 105, 236, 364, 156, 448, 810, 224, 507, 746, 766, 26, 252, 849, 917, 448, 629, 816, 838, 223, 768, 936, 271, 406, 145, 578, 938, 34, 958, 807, 694, 905, 468, 185, 122, 621, 516, 87, 421, 416, 357, 499, 406, 664, 192, 821, 164, 136, 244, 571, 984, 415, 278, 204, 412, 647, 633, 982, 689, 900, 532, 162, 222, 739, 634, 625, 774, 557, 199, 473, 133, 817, 780, 407, 882, 579, 636, 329, 637, 298, 211, 83, 707, 701, 967, 456, 948, 362, 674, 747, 155, 84, 116, 752, 200, 777, 926, 94, 926, 11, 380, 463, 499, 436, 365, 268, 182, 36, 215, 491, 137, 175, 198, 458, 450, 772, 815, 664, 838, 3, 307, 306, 330, 902, 99, 954, 86, 506, 541, 97, 912, 876, 855, 612, 131, 844, 908, 466, 278, 731, 790, 927, 206, 98, 164, 806, 894, 420, 199, 127, 590, 467, 531, 771, 966, 596, 510, 341, 709, 4, 355, 363, 163, 746, 576, 781, 720, 56, 859, 314, 220, 879, 355, 786, 689, 433, 133, 95, 95, 147, 48, 665, 498, 204, 344, 261, 184, 26, 730, 626, 640, 166, 638, 429, 727, 734, 193, 69, 663, 673, 600, 907, 25, 21, 203, 223, 470, 337, 829, 66, 250, 610, 25, 269, 66, 864, 511, 341, 219, 606, 631, 17, 101, 804, 790, 968, 112, 215, 906, 585, 748, 594, 224, 574, 249, 80, 90, 335, 324, 4, 891, 852, 51, 952, 21, 555, 379, 698, 667, 881, 326, 732, 47, 867, 866, 349, 318, 363, 509, 23, 222, 158, 49, 937, 249, 929, 37, 91, 130, 467, 699, 61, 242, 414, 708, 130, 637, 812, 496, 369, 595, 457, 955, 134, 571, 85] 928))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (lengthOfLongestSubsequence [238, 717, 518, 445, 767, 289, 205, 849, 230, 267, 807, 184, 572, 659, 942, 158, 848, 151, 150, 659, 540, 595, 741, 811, 476, 820, 251, 822, 678, 545, 804, 231, 304, 271, 803, 222, 466, 278, 353, 672, 903, 330, 321, 961] 861)," 4 (lengthOfLongestSubsequence [238, 717, 518, 445, 767, 289, 205, 849, 230, 267, 807, 184, 572, 659, 942, 158, 848, 151, 150, 659, 540, 595, 741, 811, 476, 820, 251, 822, 678, 545, 804, 231, 304, 271, 803, 222, 466, 278, 353, 672, 903, 330, 321, 961] 861))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (lengthOfLongestSubsequence [163, 461, 131, 267, 469, 811, 384, 749, 262, 988, 413, 876, 763, 461, 519, 777, 243, 248, 878, 170, 90, 801, 104, 340, 483, 216, 890, 125, 967, 695, 596, 264, 694, 780, 186, 60, 854, 571, 323, 281, 183, 695, 278, 761, 277, 793, 55, 276, 188, 827, 846, 673, 514, 3, 334, 817, 982, 942, 528, 735, 12, 968, 740, 54, 365, 392, 798, 443, 67, 793, 63, 371, 642, 258, 870, 783, 381, 921, 562, 750, 151, 963, 474, 998, 515, 903, 258, 183, 454, 679, 814, 888, 837, 822, 845, 75, 430, 663, 509, 941, 523, 415, 678, 242, 974, 894, 606, 541, 614, 76, 795, 374, 449, 13, 422, 292, 764, 640, 238, 411, 586, 495, 904, 773, 827, 810, 131, 771, 517, 11, 167, 350, 289, 7, 998, 566, 230, 662, 925, 429, 287, 435, 94, 344, 478, 538, 932, 518, 652, 650, 870, 124, 425, 611, 541, 347, 775, 541, 292, 93, 592, 809, 267, 567, 252, 705, 450, 531, 780, 295, 468, 946, 961, 515, 529, 772, 856, 64, 955, 850, 190, 153, 481, 438] 100)," 6 (lengthOfLongestSubsequence [163, 461, 131, 267, 469, 811, 384, 749, 262, 988, 413, 876, 763, 461, 519, 777, 243, 248, 878, 170, 90, 801, 104, 340, 483, 216, 890, 125, 967, 695, 596, 264, 694, 780, 186, 60, 854, 571, 323, 281, 183, 695, 278, 761, 277, 793, 55, 276, 188, 827, 846, 673, 514, 3, 334, 817, 982, 942, 528, 735, 12, 968, 740, 54, 365, 392, 798, 443, 67, 793, 63, 371, 642, 258, 870, 783, 381, 921, 562, 750, 151, 963, 474, 998, 515, 903, 258, 183, 454, 679, 814, 888, 837, 822, 845, 75, 430, 663, 509, 941, 523, 415, 678, 242, 974, 894, 606, 541, 614, 76, 795, 374, 449, 13, 422, 292, 764, 640, 238, 411, 586, 495, 904, 773, 827, 810, 131, 771, 517, 11, 167, 350, 289, 7, 998, 566, 230, 662, 925, 429, 287, 435, 94, 344, 478, 538, 932, 518, 652, 650, 870, 124, 425, 611, 541, 347, 775, 541, 292, 93, 592, 809, 267, 567, 252, 705, 450, 531, 780, 295, 468, 946, 961, 515, 529, 772, 856, 64, 955, 850, 190, 153, 481, 438] 100))
37
+
38
+
39
+ -- Grouping test cases
40
+ tests :: Test
41
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
length_of_the_longest_subsequence_that_sums_to_target/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, lengthOfLongestSubsequence(new ArrayList<>(Arrays.asList(1,2,3,4,5)), 9));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, lengthOfLongestSubsequence(new ArrayList<>(Arrays.asList(4,1,3,2,1,5)), 7));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(-1, lengthOfLongestSubsequence(new ArrayList<>(Arrays.asList(1,1,5,4,5)), 3));
23
+ }
24
+
25
+ }
length_of_the_longest_subsequence_that_sums_to_target/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
length_of_the_longest_subsequence_that_sums_to_target/ocaml_tests/main.ml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (lengthOfLongestSubsequence [1;2;3;4;5] 9)
12
+
13
+ let test2 _ = assert_equal 4 (lengthOfLongestSubsequence [4;1;3;2;1;5] 7)
14
+
15
+ let test3 _ = assert_equal (-1) (lengthOfLongestSubsequence [1;1;5;4;5] 3)
16
+
17
+ let test4 _ = assert_equal 37 (lengthOfLongestSubsequence [531; 193; 87; 198; 366; 469; 928; 314; 99; 217; 198; 228; 593; 695; 958; 189; 751; 290; 717; 696; 566; 469; 795; 810; 984; 36; 10; 629; 141; 161; 936; 741; 295; 146; 855; 543; 694; 643; 408; 476; 769; 558; 639; 446; 114; 123; 263; 839; 482; 289; 848; 706; 212; 758; 4; 261; 665; 873; 898; 392; 448; 649; 306; 564; 256; 882; 560; 165; 768; 123; 521; 492; 786; 831; 183; 189; 337; 942; 469; 295; 299; 712; 808; 196; 115; 844; 608; 171; 206; 610; 270; 107; 528; 675; 581; 228; 326; 713; 708; 928; 720; 586; 840; 720; 559; 517; 922; 45; 342; 975; 620; 590; 929; 796; 581; 960; 802; 229; 698; 866; 611; 155; 770; 660; 53; 400; 965; 291; 905; 320; 720; 218; 641; 850; 245; 112; 75; 202; 688; 642; 421; 851; 412; 671; 518; 916; 676; 186; 960; 184; 877; 898; 343; 703; 87; 894; 240; 321; 960; 901; 110; 745; 672; 665; 750; 487; 707; 914; 956; 265; 719; 611; 556; 825; 301; 70; 763; 405; 878; 189; 118; 6; 603; 239; 334; 732; 498; 814; 859; 865; 79; 83; 480; 445; 62; 688; 527; 722; 66; 69; 78; 837; 50; 617; 458; 784; 479; 914; 50; 923; 782; 345; 712; 80; 22; 367; 867; 774; 122; 255; 477; 922; 931; 688; 855; 213; 311; 854; 786; 340; 876; 636; 714; 104; 891; 407; 611; 115; 833; 950; 194; 60; 350; 137; 480; 980; 175; 861; 301; 170; 162; 560; 224; 430; 427; 395; 569; 871; 942; 707; 788; 295; 99; 180; 121; 775; 651; 865; 597; 938; 385; 798; 796; 101; 143; 51; 845; 294; 785; 894; 646; 172; 698; 342; 260; 615; 254; 571; 607; 639; 833; 829; 480; 507; 924; 886; 954; 271; 177; 154; 342; 101; 258; 521; 274; 175; 475; 639; 569; 981; 542; 636; 781; 520; 801; 453; 506; 986; 832; 550; 476; 814; 54; 207; 73; 229; 909; 302; 333; 25; 752; 155; 931; 154; 39; 194; 713; 872; 241; 546; 321; 440; 882; 50; 131; 272; 105; 509; 455; 649; 178; 225; 637; 744; 766; 374; 421; 213; 175; 474; 546; 97; 104; 613; 944; 997; 881; 611; 987; 594; 388; 698; 952; 981; 772; 79; 89; 433; 191; 574; 161; 630; 586; 767; 945; 227; 660; 397; 161; 76; 759; 552; 560; 830; 101; 642; 745; 740; 591; 272; 435; 437; 747; 753; 719; 486; 343; 140; 968; 308; 450; 187; 129; 608; 613; 241; 634; 321; 418; 516; 994; 330; 318; 920; 859; 705; 646; 156; 907; 711; 300; 544; 363; 123; 162; 88; 577; 931; 737; 477; 307; 111; 42; 978; 380; 49; 548; 693; 615; 159; 712; 747; 67; 132; 67; 806; 19; 887; 962; 247; 757; 809; 380; 126; 673; 367; 727; 214; 223; 630; 322; 641; 757; 200; 406; 30; 44; 534; 63; 30; 615; 914; 499; 59; 972; 68; 665; 154; 183; 884; 551; 412; 866; 753; 105; 159; 577; 763; 228; 540; 331; 764; 846; 304; 31; 306; 846; 202; 798; 15; 848; 40; 66; 244; 170; 567; 658; 800; 515; 832; 151; 459; 399; 871; 449; 945; 706; 482; 695; 932; 347; 87; 398; 8; 8; 170; 73; 937; 660; 98; 127; 791; 826; 657; 21; 664; 936; 278; 715; 665; 890; 546; 206; 697; 166; 873; 436; 845; 243; 991; 43; 803; 404; 871; 477; 618; 88; 786; 343; 422; 53; 725; 120; 959; 755; 741; 914; 906; 606; 742; 580; 439; 823; 507; 775; 505; 128; 134; 563; 885; 922; 995; 242; 778; 125; 569; 972; 481; 693; 978; 538; 134; 907; 29; 92; 172; 978; 555; 85; 670; 312; 891; 780; 810; 813; 3; 484; 620; 327; 590; 459; 581; 34; 608; 328; 965; 43; 867; 788; 299; 358; 966; 709; 563; 697; 15; 383; 552; 857; 667; 416; 911; 765; 535; 85; 113; 986; 526; 518; 474; 243; 265; 358; 541; 839; 214; 95; 399; 809; 234; 674; 434; 523; 200; 606; 696; 536; 943; 990; 320; 928; 724; 549; 789; 132; 774; 582; 23; 538; 839; 323; 306; 217; 866; 935; 320; 850; 98; 360; 702; 427; 31; 271; 691; 737; 549; 742; 43; 846; 8; 950; 446; 188; 846; 661; 653; 590; 8; 52; 148; 572; 281; 355; 958; 350; 131; 745; 870; 99; 956; 471; 792; 499; 134; 231; 606; 942; 817; 27; 7; 288; 453; 327; 281; 357; 541; 920; 152; 413; 218; 771; 786; 440; 19; 124; 713; 798; 296; 492; 280; 119; 91; 969; 517; 164; 623; 351; 398; 801; 264; 206; 806; 500; 884; 919; 950; 677; 508; 504; 36; 972; 884; 185; 86; 182; 58; 994; 4; 854; 321; 205; 12; 495; 20; 66; 551; 93; 417; 885; 643; 882; 995; 244; 414; 379; 344; 588; 85; 37; 430; 582; 212; 109; 790; 159; 276; 366; 644; 297; 928; 584; 510; 259; 180; 357; 859; 737; 843; 2; 205; 683; 428; 250; 939; 778; 945; 669; 25; 911; 250; 129; 972; 856; 53; 31; 111; 378; 328; 756; 149; 250; 719; 700; 578; 22; 48; 266; 634; 732; 214; 361; 979; 229; 691; 279; 112; 405; 544; 815; 828; 97; 217; 61; 286; 813; 2; 102; 882; 473; 255; 81; 1000; 466; 450; 209] 767)
18
+
19
+ let test5 _ = assert_equal 22 (lengthOfLongestSubsequence [297; 353; 392; 129; 520; 66; 999; 72; 771; 595; 709; 573; 12; 307; 40; 933; 26; 485; 862; 93; 601; 615; 796; 368; 654; 518; 396; 426; 624; 541; 58; 915; 950; 753; 489; 381; 447; 793; 369; 108; 805; 509; 382; 525; 142; 38; 110; 284; 49; 512; 56; 307; 806; 842; 580; 881; 379; 127; 409; 445; 222; 936; 257; 523; 718; 818; 581; 908; 569; 347; 221; 919; 308; 70; 900; 310; 851; 818; 740; 368; 908; 118; 258; 171; 582; 104; 453; 782; 451; 690; 135; 579; 907; 4; 502; 954; 747; 654; 415; 522; 5; 78; 447; 641; 492; 453; 608; 744; 971; 337; 889; 415; 927; 350; 451; 229; 176; 241; 371; 864; 221; 110; 83; 103; 160; 502; 259; 74; 90; 821; 431; 370; 74; 140; 525; 585; 637; 530; 141; 744; 701; 414; 146; 970; 705; 549; 496; 731; 189; 907; 29; 593; 159; 974; 524; 643; 39; 737; 729; 192; 215; 444; 174; 799; 988; 723; 827; 333; 591; 173; 668; 17; 513; 260; 318; 453; 38; 360; 226; 664; 107; 985; 906; 726; 302; 806; 292; 982; 580; 684; 154; 547; 233; 509; 790; 478; 619; 306; 998; 476; 928; 450; 841; 409; 564; 841; 97; 807; 700; 977; 373; 695; 626; 178; 380; 657; 497; 188; 668; 132; 297; 20; 651; 905; 993; 749; 944; 280; 314; 69; 83; 220; 220; 348; 895; 811; 824; 911; 261; 153; 598; 611; 605; 825; 773; 43; 651; 31; 387; 989; 321; 821; 933; 574; 266; 909; 165; 935; 112; 712; 170; 699; 48; 694; 619; 968; 930; 265; 680; 365; 216; 701; 781; 421; 966; 835; 518; 484; 251; 431; 630; 872; 724; 251; 213; 660; 603; 760; 100; 771; 580; 592; 206; 579; 769; 19; 343; 933; 453; 184] 887)
20
+
21
+ let test6 _ = assert_equal 29 (lengthOfLongestSubsequence [712; 345; 180; 787; 698; 248; 871; 945; 614; 122; 72; 307; 573; 648; 260; 917; 442; 495; 332; 48; 313; 969; 66; 225; 469; 800; 549; 392; 651; 211; 111; 596; 332; 752; 311; 140; 322; 282; 174; 405; 527; 447; 953; 348; 230; 15; 367; 975; 733; 270; 749; 216; 30; 530; 392; 709; 958; 76; 604; 49; 934; 255; 184; 662; 63; 450; 402; 298; 418; 824; 234; 827; 898; 657; 748; 880; 831; 252; 751; 632; 324; 84; 570; 17; 360; 58; 56; 425; 424; 924; 970; 568; 112; 934; 32; 403; 642; 380; 229; 905; 903; 242; 170; 754; 709; 117; 38; 261; 684; 884; 38; 589; 394; 789; 629; 526; 835; 516; 452; 811; 550; 163; 526; 546; 887; 512; 532; 417; 946; 205; 714; 131; 390; 884; 864; 665; 404; 594; 816; 716; 217; 618; 986; 692; 983; 662; 239; 83; 706; 874; 318; 403; 851; 150; 540; 502; 569; 273; 177; 70; 652; 156; 789; 912; 3; 639; 803; 634; 691; 907; 717; 89; 806; 47; 432; 144; 451; 895; 784; 609; 916; 282; 775; 645; 498; 386; 252; 648; 920; 446; 349; 762; 760; 382; 791; 4; 193; 449; 953; 108; 300; 596; 464; 473; 27; 142; 847; 154; 565; 974; 782; 565; 914; 369; 800; 899; 21; 391; 815; 515; 890; 557; 636; 825; 391; 443; 415; 643; 229; 504; 680; 989; 737; 398; 666; 405; 921; 314; 855; 485; 163; 785; 483; 62; 599; 361; 630; 28; 742; 459; 382; 683; 989; 158; 116; 888; 339; 173; 855; 209; 456; 488; 590; 673; 173; 641; 31; 899; 718; 87; 786; 515; 208; 153; 833; 398; 855; 61; 16; 632; 847; 792; 469; 666; 868; 321; 818; 369; 683; 384; 549; 827; 490; 503; 786; 117; 833; 398; 298; 636; 757; 169; 442; 867; 633; 283; 796; 79; 540; 56; 133; 826; 163; 1; 422; 203; 221; 976; 849; 962; 284; 331; 203; 886; 263; 388; 446; 416; 166; 240; 650; 440; 829; 862; 172; 895; 164; 811; 944; 773; 328; 574; 91; 449; 841; 851; 579; 223; 126; 822; 903; 938; 381; 696; 946; 668; 443; 993; 117; 694; 693; 447; 98; 57; 280; 159; 63; 474; 746; 980; 629; 589; 311; 392; 4; 585; 788; 7; 46; 453; 125; 9; 367; 293; 846; 720; 609; 129; 563; 650; 459; 283; 239; 391; 881; 520; 97; 332; 29; 915; 489; 985; 406; 53; 578; 674; 612; 34; 428; 860; 610; 360; 517; 951; 509; 571; 899; 163; 256; 237; 411; 103; 539; 566; 808; 965; 837; 403; 684; 929; 118; 708; 826; 647; 720; 402; 797; 260; 921; 914; 127; 258; 314; 870; 908; 215; 765; 176; 719; 497; 105; 130; 203; 583; 858; 696; 956; 819; 852; 96; 514; 939; 694; 446; 269; 327; 793; 892; 773; 873; 457; 336; 297; 177; 730; 354; 767; 642; 93; 724; 734; 588; 928; 87; 473; 210; 208; 405; 650; 723; 802; 123; 337; 400; 509; 781; 839; 507; 286; 38; 133; 984; 247; 949; 251; 227; 538; 662; 685; 371; 199; 448; 688; 102; 156; 447; 144; 924; 782; 43; 402; 418; 704; 677; 925; 1000; 907; 940; 111; 551; 932; 412; 153; 103; 903; 605; 44; 141; 80; 537; 729; 399; 811; 495; 609; 409; 901; 233; 432; 279; 17; 87; 13; 759; 887; 602; 428; 400; 757; 799; 49; 840; 357; 507; 434; 755; 350; 454; 943; 517; 427; 65; 183; 891; 195; 915; 250; 428; 808; 257; 939; 682; 993; 890; 938; 653; 665; 204; 450; 127; 451; 788; 466; 567; 167; 169; 494; 124; 972; 631; 261; 529; 763; 743; 354; 445; 399; 860; 13; 653; 392; 406; 555; 25; 473; 530; 327; 365; 659; 906; 525; 789; 490; 506; 479; 547; 602; 923; 923; 923; 197; 73; 769; 523; 185; 420; 192; 831; 398; 234; 120; 229; 841; 77; 561; 103; 809; 222; 216; 941; 459; 110; 385; 968; 824; 812; 13; 246; 546; 738; 55; 3; 598; 739; 623; 178; 387; 613; 788; 372; 490; 593; 434; 522; 574; 878; 64; 739; 400; 437; 329; 262; 656; 324; 659; 276; 576; 229; 22; 861; 245; 736; 927; 887; 767; 388; 820; 872; 199; 731; 451; 296; 425; 482; 541; 524; 254; 659; 572; 190; 556; 764; 107; 464; 148; 56; 199; 295; 745; 398; 827; 905; 475; 430; 727; 280; 253; 404; 159; 770; 172; 888; 115; 295; 609; 400; 366; 122; 948; 455; 181; 868; 686; 493; 34; 921; 52; 462; 97; 12; 163; 512; 961; 482; 791; 863; 143; 528; 387; 412; 949; 16; 913; 726; 596; 332; 19; 887; 901; 707; 840; 842; 216; 893; 802; 401; 974; 576; 735; 626; 322; 595; 109; 919; 283; 507; 991; 987; 86; 145; 741; 856; 386; 292; 80; 161; 835; 845; 571; 69; 100; 530; 492; 945; 524; 706; 389; 110; 150; 384; 147; 570; 80; 290; 853; 992; 491; 826; 397; 803; 784; 176; 566; 474; 50; 830; 988; 632; 754; 193; 961; 663; 193; 257; 456; 114; 522; 177; 567; 701; 876; 439; 670; 808; 841; 661; 960; 564; 211; 874; 963; 791; 846; 308; 183; 719; 394; 815; 974; 296; 845; 301; 954; 795; 575; 736; 917; 201; 798; 930; 814; 313; 892; 714; 918; 314; 504; 828; 959; 534; 97; 886; 656; 609; 194; 731; 302; 692; 633; 716; 956; 556] 542)
22
+
23
+ let test7 _ = assert_equal 25 (lengthOfLongestSubsequence [491; 307; 163; 565; 187; 374; 825; 118; 74; 279; 352; 225; 996; 514; 718; 832; 473; 527; 872; 91; 861; 597; 300; 445; 986; 698; 903; 781; 827; 939; 544; 893; 557; 105; 236; 364; 156; 448; 810; 224; 507; 746; 766; 26; 252; 849; 917; 448; 629; 816; 838; 223; 768; 936; 271; 406; 145; 578; 938; 34; 958; 807; 694; 905; 468; 185; 122; 621; 516; 87; 421; 416; 357; 499; 406; 664; 192; 821; 164; 136; 244; 571; 984; 415; 278; 204; 412; 647; 633; 982; 689; 900; 532; 162; 222; 739; 634; 625; 774; 557; 199; 473; 133; 817; 780; 407; 882; 579; 636; 329; 637; 298; 211; 83; 707; 701; 967; 456; 948; 362; 674; 747; 155; 84; 116; 752; 200; 777; 926; 94; 926; 11; 380; 463; 499; 436; 365; 268; 182; 36; 215; 491; 137; 175; 198; 458; 450; 772; 815; 664; 838; 3; 307; 306; 330; 902; 99; 954; 86; 506; 541; 97; 912; 876; 855; 612; 131; 844; 908; 466; 278; 731; 790; 927; 206; 98; 164; 806; 894; 420; 199; 127; 590; 467; 531; 771; 966; 596; 510; 341; 709; 4; 355; 363; 163; 746; 576; 781; 720; 56; 859; 314; 220; 879; 355; 786; 689; 433; 133; 95; 95; 147; 48; 665; 498; 204; 344; 261; 184; 26; 730; 626; 640; 166; 638; 429; 727; 734; 193; 69; 663; 673; 600; 907; 25; 21; 203; 223; 470; 337; 829; 66; 250; 610; 25; 269; 66; 864; 511; 341; 219; 606; 631; 17; 101; 804; 790; 968; 112; 215; 906; 585; 748; 594; 224; 574; 249; 80; 90; 335; 324; 4; 891; 852; 51; 952; 21; 555; 379; 698; 667; 881; 326; 732; 47; 867; 866; 349; 318; 363; 509; 23; 222; 158; 49; 937; 249; 929; 37; 91; 130; 467; 699; 61; 242; 414; 708; 130; 637; 812; 496; 369; 595; 457; 955; 134; 571; 85] 928)
24
+
25
+ let test8 _ = assert_equal 4 (lengthOfLongestSubsequence [238; 717; 518; 445; 767; 289; 205; 849; 230; 267; 807; 184; 572; 659; 942; 158; 848; 151; 150; 659; 540; 595; 741; 811; 476; 820; 251; 822; 678; 545; 804; 231; 304; 271; 803; 222; 466; 278; 353; 672; 903; 330; 321; 961] 861)
26
+
27
+ let test9 _ = assert_equal 6 (lengthOfLongestSubsequence [163; 461; 131; 267; 469; 811; 384; 749; 262; 988; 413; 876; 763; 461; 519; 777; 243; 248; 878; 170; 90; 801; 104; 340; 483; 216; 890; 125; 967; 695; 596; 264; 694; 780; 186; 60; 854; 571; 323; 281; 183; 695; 278; 761; 277; 793; 55; 276; 188; 827; 846; 673; 514; 3; 334; 817; 982; 942; 528; 735; 12; 968; 740; 54; 365; 392; 798; 443; 67; 793; 63; 371; 642; 258; 870; 783; 381; 921; 562; 750; 151; 963; 474; 998; 515; 903; 258; 183; 454; 679; 814; 888; 837; 822; 845; 75; 430; 663; 509; 941; 523; 415; 678; 242; 974; 894; 606; 541; 614; 76; 795; 374; 449; 13; 422; 292; 764; 640; 238; 411; 586; 495; 904; 773; 827; 810; 131; 771; 517; 11; 167; 350; 289; 7; 998; 566; 230; 662; 925; 429; 287; 435; 94; 344; 478; 538; 932; 518; 652; 650; 870; 124; 425; 611; 541; 347; 775; 541; 292; 93; 592; 809; 267; 567; 252; 705; 450; 531; 780; 295; 468; 946; 961; 515; 529; 772; 856; 64; 955; 850; 190; 153; 481; 438] 100)
28
+
29
+ let test10 _ = assert_equal 18 (lengthOfLongestSubsequence [171; 608; 71; 229; 753; 460; 300; 639; 366; 819; 383; 890; 132; 261; 96; 273; 27; 928; 820; 359; 772; 640; 412; 841; 96; 847; 996; 952; 208; 593; 797; 153; 293; 264; 294; 496; 750; 710; 861; 411; 562; 343; 176; 752; 403; 239; 788; 583; 97; 803; 597; 972; 436; 653; 270; 651; 203; 756; 93; 397; 618; 266; 984; 972; 583; 501; 618; 4; 380; 338; 568; 495; 549; 752; 850; 872; 453; 959; 914; 805; 270; 271; 666; 685; 989; 197; 59; 214; 964; 725; 261; 255; 466; 776; 524; 140; 578; 619; 676; 818; 830; 427; 426; 585; 948; 949; 901; 545; 448; 382; 403; 644; 151; 842; 139; 597; 908; 196; 240; 73; 338; 759; 781; 549; 667; 730; 984; 267; 450; 905; 908; 856; 889; 784; 982; 471; 991; 993; 205; 103; 292; 46; 879; 737; 39; 133; 244; 820; 791; 907; 104; 413; 836; 417; 20; 569; 729; 983; 606; 330; 695; 831; 939; 483; 531; 405; 810; 365; 13; 687; 37; 296; 96; 749; 919; 200; 717; 668; 726; 972; 773; 747; 171; 473; 200; 86; 967; 424; 695; 475; 244; 535; 920; 518; 549; 622; 169; 736; 957; 229; 559; 180; 27; 802; 802; 730; 546; 209; 86; 227; 559; 288; 113; 656; 69; 604; 773; 346; 614; 92; 912; 896; 731; 499; 232; 616; 695; 101; 299; 492; 761; 45; 225; 975; 477; 19; 445; 673; 459; 414; 442; 848; 806; 370; 110; 629; 900; 954; 335; 688; 467; 950; 130; 127; 97; 780; 221; 529; 123; 277; 73; 617; 501; 383; 746; 304; 312; 752; 400; 472; 615; 727; 891; 137; 725; 904; 186; 867; 895; 143; 442; 998; 645; 958; 339; 315; 632; 152; 553; 584; 880; 645; 164; 697; 607; 227; 961; 735; 825; 353; 755; 83; 782; 723; 623; 549; 882; 978; 150; 695; 351; 635; 153; 687; 776; 455; 881; 829; 927; 789; 317; 290; 943; 475; 592; 336; 848; 618; 828; 249; 297; 644; 448; 479; 506; 323; 442; 84; 186; 956; 843; 653; 153; 185; 973; 230; 657; 146; 647; 120; 255; 182; 845; 631; 14; 622; 642; 650; 149; 769; 982; 467; 896; 825; 698; 458; 296; 775; 994; 681; 219; 331; 741; 267; 14; 142; 178; 321; 415; 721; 233; 631; 456; 213; 444; 181; 281; 121; 347; 144; 876; 535; 954; 53; 148; 933; 133; 403; 121; 666; 679; 523; 973; 246; 21; 202; 200; 285; 631; 869; 92; 33; 675; 678; 167; 418; 8; 812; 146; 433; 784; 983; 31; 581; 691; 750; 81; 937; 391; 129; 218; 131; 305; 132; 398; 495; 350; 250; 236; 724; 278; 979; 259; 304; 409; 619; 295; 659; 242; 552; 442; 95; 595; 204; 423; 515; 764; 80; 873; 54; 742; 548; 969; 287; 490; 867; 99; 743; 267; 199; 888; 216; 782; 352; 512; 516; 943; 305; 143; 556; 476; 891; 748; 508; 918; 764; 711; 561; 81; 726; 607; 923; 1000; 181; 602; 917; 33; 235; 247; 895; 293; 893; 790; 399; 567; 585; 927; 483; 781; 641; 505; 517; 420; 751; 153; 273; 297; 904; 823; 781; 451; 775; 966; 531; 161; 997; 641; 337; 995; 955; 757; 340; 793; 828; 74; 372; 395; 119; 138; 378; 972; 397; 421; 663; 411; 723; 514; 528; 173; 524; 28; 605; 193; 286; 598; 966; 540; 758; 871; 682; 997; 762; 410; 191; 11; 871; 902; 713; 298; 987; 52; 378; 960; 605; 614; 709; 538; 84; 360; 572; 844; 343; 834; 291; 129; 932; 166; 966; 725; 190; 412; 770; 966; 570; 628; 34; 220; 891; 130; 417; 44; 517; 522; 606; 189; 254; 901; 367; 556; 797; 355; 989; 376; 850; 826; 619; 597; 67; 778; 753; 770; 902; 320; 691; 261; 406; 372; 244; 941; 729; 84; 123; 296; 108; 111; 838; 9; 428; 215; 884; 686; 947; 110; 570; 881; 606; 450; 488; 495; 847; 733; 273; 255; 205; 831; 538; 59; 47; 479; 68; 903; 687; 272; 417; 114; 6; 874; 917; 212; 301; 127; 991; 731; 874; 884; 166; 440; 146] 355)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for lengthOfLongestSubsequence" >::: [
34
+
35
+ "test1" >:: test1;
36
+ "test2" >:: test2;
37
+ "test3" >:: test3;
38
+ "test4" >:: test4;
39
+ "test5" >:: test5;
40
+ "test6" >:: test6;
41
+ "test7" >:: test7;
42
+ "test8" >:: test8;
43
+ "test9" >:: test9;
44
+ "test10" >:: test10;
45
+ ]
46
+
47
+
48
+ (* Running the tests *)
49
+ let () = run_test_tt_main suite
50
+ end
length_of_the_longest_subsequence_that_sums_to_target/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.lengthOfLongestSubsequence(List(1,2,3,4,5),9), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.lengthOfLongestSubsequence(List(4,1,3,2,1,5),7), 4)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.lengthOfLongestSubsequence(List(1,1,5,4,5),3), -1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.lengthOfLongestSubsequence(List(531, 193, 87, 198, 366, 469, 928, 314, 99, 217, 198, 228, 593, 695, 958, 189, 751, 290, 717, 696, 566, 469, 795, 810, 984, 36, 10, 629, 141, 161, 936, 741, 295, 146, 855, 543, 694, 643, 408, 476, 769, 558, 639, 446, 114, 123, 263, 839, 482, 289, 848, 706, 212, 758, 4, 261, 665, 873, 898, 392, 448, 649, 306, 564, 256, 882, 560, 165, 768, 123, 521, 492, 786, 831, 183, 189, 337, 942, 469, 295, 299, 712, 808, 196, 115, 844, 608, 171, 206, 610, 270, 107, 528, 675, 581, 228, 326, 713, 708, 928, 720, 586, 840, 720, 559, 517, 922, 45, 342, 975, 620, 590, 929, 796, 581, 960, 802, 229, 698, 866, 611, 155, 770, 660, 53, 400, 965, 291, 905, 320, 720, 218, 641, 850, 245, 112, 75, 202, 688, 642, 421, 851, 412, 671, 518, 916, 676, 186, 960, 184, 877, 898, 343, 703, 87, 894, 240, 321, 960, 901, 110, 745, 672, 665, 750, 487, 707, 914, 956, 265, 719, 611, 556, 825, 301, 70, 763, 405, 878, 189, 118, 6, 603, 239, 334, 732, 498, 814, 859, 865, 79, 83, 480, 445, 62, 688, 527, 722, 66, 69, 78, 837, 50, 617, 458, 784, 479, 914, 50, 923, 782, 345, 712, 80, 22, 367, 867, 774, 122, 255, 477, 922, 931, 688, 855, 213, 311, 854, 786, 340, 876, 636, 714, 104, 891, 407, 611, 115, 833, 950, 194, 60, 350, 137, 480, 980, 175, 861, 301, 170, 162, 560, 224, 430, 427, 395, 569, 871, 942, 707, 788, 295, 99, 180, 121, 775, 651, 865, 597, 938, 385, 798, 796, 101, 143, 51, 845, 294, 785, 894, 646, 172, 698, 342, 260, 615, 254, 571, 607, 639, 833, 829, 480, 507, 924, 886, 954, 271, 177, 154, 342, 101, 258, 521, 274, 175, 475, 639, 569, 981, 542, 636, 781, 520, 801, 453, 506, 986, 832, 550, 476, 814, 54, 207, 73, 229, 909, 302, 333, 25, 752, 155, 931, 154, 39, 194, 713, 872, 241, 546, 321, 440, 882, 50, 131, 272, 105, 509, 455, 649, 178, 225, 637, 744, 766, 374, 421, 213, 175, 474, 546, 97, 104, 613, 944, 997, 881, 611, 987, 594, 388, 698, 952, 981, 772, 79, 89, 433, 191, 574, 161, 630, 586, 767, 945, 227, 660, 397, 161, 76, 759, 552, 560, 830, 101, 642, 745, 740, 591, 272, 435, 437, 747, 753, 719, 486, 343, 140, 968, 308, 450, 187, 129, 608, 613, 241, 634, 321, 418, 516, 994, 330, 318, 920, 859, 705, 646, 156, 907, 711, 300, 544, 363, 123, 162, 88, 577, 931, 737, 477, 307, 111, 42, 978, 380, 49, 548, 693, 615, 159, 712, 747, 67, 132, 67, 806, 19, 887, 962, 247, 757, 809, 380, 126, 673, 367, 727, 214, 223, 630, 322, 641, 757, 200, 406, 30, 44, 534, 63, 30, 615, 914, 499, 59, 972, 68, 665, 154, 183, 884, 551, 412, 866, 753, 105, 159, 577, 763, 228, 540, 331, 764, 846, 304, 31, 306, 846, 202, 798, 15, 848, 40, 66, 244, 170, 567, 658, 800, 515, 832, 151, 459, 399, 871, 449, 945, 706, 482, 695, 932, 347, 87, 398, 8, 8, 170, 73, 937, 660, 98, 127, 791, 826, 657, 21, 664, 936, 278, 715, 665, 890, 546, 206, 697, 166, 873, 436, 845, 243, 991, 43, 803, 404, 871, 477, 618, 88, 786, 343, 422, 53, 725, 120, 959, 755, 741, 914, 906, 606, 742, 580, 439, 823, 507, 775, 505, 128, 134, 563, 885, 922, 995, 242, 778, 125, 569, 972, 481, 693, 978, 538, 134, 907, 29, 92, 172, 978, 555, 85, 670, 312, 891, 780, 810, 813, 3, 484, 620, 327, 590, 459, 581, 34, 608, 328, 965, 43, 867, 788, 299, 358, 966, 709, 563, 697, 15, 383, 552, 857, 667, 416, 911, 765, 535, 85, 113, 986, 526, 518, 474, 243, 265, 358, 541, 839, 214, 95, 399, 809, 234, 674, 434, 523, 200, 606, 696, 536, 943, 990, 320, 928, 724, 549, 789, 132, 774, 582, 23, 538, 839, 323, 306, 217, 866, 935, 320, 850, 98, 360, 702, 427, 31, 271, 691, 737, 549, 742, 43, 846, 8, 950, 446, 188, 846, 661, 653, 590, 8, 52, 148, 572, 281, 355, 958, 350, 131, 745, 870, 99, 956, 471, 792, 499, 134, 231, 606, 942, 817, 27, 7, 288, 453, 327, 281, 357, 541, 920, 152, 413, 218, 771, 786, 440, 19, 124, 713, 798, 296, 492, 280, 119, 91, 969, 517, 164, 623, 351, 398, 801, 264, 206, 806, 500, 884, 919, 950, 677, 508, 504, 36, 972, 884, 185, 86, 182, 58, 994, 4, 854, 321, 205, 12, 495, 20, 66, 551, 93, 417, 885, 643, 882, 995, 244, 414, 379, 344, 588, 85, 37, 430, 582, 212, 109, 790, 159, 276, 366, 644, 297, 928, 584, 510, 259, 180, 357, 859, 737, 843, 2, 205, 683, 428, 250, 939, 778, 945, 669, 25, 911, 250, 129, 972, 856, 53, 31, 111, 378, 328, 756, 149, 250, 719, 700, 578, 22, 48, 266, 634, 732, 214, 361, 979, 229, 691, 279, 112, 405, 544, 815, 828, 97, 217, 61, 286, 813, 2, 102, 882, 473, 255, 81, 1000, 466, 450, 209),767), 37)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.lengthOfLongestSubsequence(List(297, 353, 392, 129, 520, 66, 999, 72, 771, 595, 709, 573, 12, 307, 40, 933, 26, 485, 862, 93, 601, 615, 796, 368, 654, 518, 396, 426, 624, 541, 58, 915, 950, 753, 489, 381, 447, 793, 369, 108, 805, 509, 382, 525, 142, 38, 110, 284, 49, 512, 56, 307, 806, 842, 580, 881, 379, 127, 409, 445, 222, 936, 257, 523, 718, 818, 581, 908, 569, 347, 221, 919, 308, 70, 900, 310, 851, 818, 740, 368, 908, 118, 258, 171, 582, 104, 453, 782, 451, 690, 135, 579, 907, 4, 502, 954, 747, 654, 415, 522, 5, 78, 447, 641, 492, 453, 608, 744, 971, 337, 889, 415, 927, 350, 451, 229, 176, 241, 371, 864, 221, 110, 83, 103, 160, 502, 259, 74, 90, 821, 431, 370, 74, 140, 525, 585, 637, 530, 141, 744, 701, 414, 146, 970, 705, 549, 496, 731, 189, 907, 29, 593, 159, 974, 524, 643, 39, 737, 729, 192, 215, 444, 174, 799, 988, 723, 827, 333, 591, 173, 668, 17, 513, 260, 318, 453, 38, 360, 226, 664, 107, 985, 906, 726, 302, 806, 292, 982, 580, 684, 154, 547, 233, 509, 790, 478, 619, 306, 998, 476, 928, 450, 841, 409, 564, 841, 97, 807, 700, 977, 373, 695, 626, 178, 380, 657, 497, 188, 668, 132, 297, 20, 651, 905, 993, 749, 944, 280, 314, 69, 83, 220, 220, 348, 895, 811, 824, 911, 261, 153, 598, 611, 605, 825, 773, 43, 651, 31, 387, 989, 321, 821, 933, 574, 266, 909, 165, 935, 112, 712, 170, 699, 48, 694, 619, 968, 930, 265, 680, 365, 216, 701, 781, 421, 966, 835, 518, 484, 251, 431, 630, 872, 724, 251, 213, 660, 603, 760, 100, 771, 580, 592, 206, 579, 769, 19, 343, 933, 453, 184),887), 22)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.lengthOfLongestSubsequence(List(712, 345, 180, 787, 698, 248, 871, 945, 614, 122, 72, 307, 573, 648, 260, 917, 442, 495, 332, 48, 313, 969, 66, 225, 469, 800, 549, 392, 651, 211, 111, 596, 332, 752, 311, 140, 322, 282, 174, 405, 527, 447, 953, 348, 230, 15, 367, 975, 733, 270, 749, 216, 30, 530, 392, 709, 958, 76, 604, 49, 934, 255, 184, 662, 63, 450, 402, 298, 418, 824, 234, 827, 898, 657, 748, 880, 831, 252, 751, 632, 324, 84, 570, 17, 360, 58, 56, 425, 424, 924, 970, 568, 112, 934, 32, 403, 642, 380, 229, 905, 903, 242, 170, 754, 709, 117, 38, 261, 684, 884, 38, 589, 394, 789, 629, 526, 835, 516, 452, 811, 550, 163, 526, 546, 887, 512, 532, 417, 946, 205, 714, 131, 390, 884, 864, 665, 404, 594, 816, 716, 217, 618, 986, 692, 983, 662, 239, 83, 706, 874, 318, 403, 851, 150, 540, 502, 569, 273, 177, 70, 652, 156, 789, 912, 3, 639, 803, 634, 691, 907, 717, 89, 806, 47, 432, 144, 451, 895, 784, 609, 916, 282, 775, 645, 498, 386, 252, 648, 920, 446, 349, 762, 760, 382, 791, 4, 193, 449, 953, 108, 300, 596, 464, 473, 27, 142, 847, 154, 565, 974, 782, 565, 914, 369, 800, 899, 21, 391, 815, 515, 890, 557, 636, 825, 391, 443, 415, 643, 229, 504, 680, 989, 737, 398, 666, 405, 921, 314, 855, 485, 163, 785, 483, 62, 599, 361, 630, 28, 742, 459, 382, 683, 989, 158, 116, 888, 339, 173, 855, 209, 456, 488, 590, 673, 173, 641, 31, 899, 718, 87, 786, 515, 208, 153, 833, 398, 855, 61, 16, 632, 847, 792, 469, 666, 868, 321, 818, 369, 683, 384, 549, 827, 490, 503, 786, 117, 833, 398, 298, 636, 757, 169, 442, 867, 633, 283, 796, 79, 540, 56, 133, 826, 163, 1, 422, 203, 221, 976, 849, 962, 284, 331, 203, 886, 263, 388, 446, 416, 166, 240, 650, 440, 829, 862, 172, 895, 164, 811, 944, 773, 328, 574, 91, 449, 841, 851, 579, 223, 126, 822, 903, 938, 381, 696, 946, 668, 443, 993, 117, 694, 693, 447, 98, 57, 280, 159, 63, 474, 746, 980, 629, 589, 311, 392, 4, 585, 788, 7, 46, 453, 125, 9, 367, 293, 846, 720, 609, 129, 563, 650, 459, 283, 239, 391, 881, 520, 97, 332, 29, 915, 489, 985, 406, 53, 578, 674, 612, 34, 428, 860, 610, 360, 517, 951, 509, 571, 899, 163, 256, 237, 411, 103, 539, 566, 808, 965, 837, 403, 684, 929, 118, 708, 826, 647, 720, 402, 797, 260, 921, 914, 127, 258, 314, 870, 908, 215, 765, 176, 719, 497, 105, 130, 203, 583, 858, 696, 956, 819, 852, 96, 514, 939, 694, 446, 269, 327, 793, 892, 773, 873, 457, 336, 297, 177, 730, 354, 767, 642, 93, 724, 734, 588, 928, 87, 473, 210, 208, 405, 650, 723, 802, 123, 337, 400, 509, 781, 839, 507, 286, 38, 133, 984, 247, 949, 251, 227, 538, 662, 685, 371, 199, 448, 688, 102, 156, 447, 144, 924, 782, 43, 402, 418, 704, 677, 925, 1000, 907, 940, 111, 551, 932, 412, 153, 103, 903, 605, 44, 141, 80, 537, 729, 399, 811, 495, 609, 409, 901, 233, 432, 279, 17, 87, 13, 759, 887, 602, 428, 400, 757, 799, 49, 840, 357, 507, 434, 755, 350, 454, 943, 517, 427, 65, 183, 891, 195, 915, 250, 428, 808, 257, 939, 682, 993, 890, 938, 653, 665, 204, 450, 127, 451, 788, 466, 567, 167, 169, 494, 124, 972, 631, 261, 529, 763, 743, 354, 445, 399, 860, 13, 653, 392, 406, 555, 25, 473, 530, 327, 365, 659, 906, 525, 789, 490, 506, 479, 547, 602, 923, 923, 923, 197, 73, 769, 523, 185, 420, 192, 831, 398, 234, 120, 229, 841, 77, 561, 103, 809, 222, 216, 941, 459, 110, 385, 968, 824, 812, 13, 246, 546, 738, 55, 3, 598, 739, 623, 178, 387, 613, 788, 372, 490, 593, 434, 522, 574, 878, 64, 739, 400, 437, 329, 262, 656, 324, 659, 276, 576, 229, 22, 861, 245, 736, 927, 887, 767, 388, 820, 872, 199, 731, 451, 296, 425, 482, 541, 524, 254, 659, 572, 190, 556, 764, 107, 464, 148, 56, 199, 295, 745, 398, 827, 905, 475, 430, 727, 280, 253, 404, 159, 770, 172, 888, 115, 295, 609, 400, 366, 122, 948, 455, 181, 868, 686, 493, 34, 921, 52, 462, 97, 12, 163, 512, 961, 482, 791, 863, 143, 528, 387, 412, 949, 16, 913, 726, 596, 332, 19, 887, 901, 707, 840, 842, 216, 893, 802, 401, 974, 576, 735, 626, 322, 595, 109, 919, 283, 507, 991, 987, 86, 145, 741, 856, 386, 292, 80, 161, 835, 845, 571, 69, 100, 530, 492, 945, 524, 706, 389, 110, 150, 384, 147, 570, 80, 290, 853, 992, 491, 826, 397, 803, 784, 176, 566, 474, 50, 830, 988, 632, 754, 193, 961, 663, 193, 257, 456, 114, 522, 177, 567, 701, 876, 439, 670, 808, 841, 661, 960, 564, 211, 874, 963, 791, 846, 308, 183, 719, 394, 815, 974, 296, 845, 301, 954, 795, 575, 736, 917, 201, 798, 930, 814, 313, 892, 714, 918, 314, 504, 828, 959, 534, 97, 886, 656, 609, 194, 731, 302, 692, 633, 716, 956, 556),542), 29)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.lengthOfLongestSubsequence(List(491, 307, 163, 565, 187, 374, 825, 118, 74, 279, 352, 225, 996, 514, 718, 832, 473, 527, 872, 91, 861, 597, 300, 445, 986, 698, 903, 781, 827, 939, 544, 893, 557, 105, 236, 364, 156, 448, 810, 224, 507, 746, 766, 26, 252, 849, 917, 448, 629, 816, 838, 223, 768, 936, 271, 406, 145, 578, 938, 34, 958, 807, 694, 905, 468, 185, 122, 621, 516, 87, 421, 416, 357, 499, 406, 664, 192, 821, 164, 136, 244, 571, 984, 415, 278, 204, 412, 647, 633, 982, 689, 900, 532, 162, 222, 739, 634, 625, 774, 557, 199, 473, 133, 817, 780, 407, 882, 579, 636, 329, 637, 298, 211, 83, 707, 701, 967, 456, 948, 362, 674, 747, 155, 84, 116, 752, 200, 777, 926, 94, 926, 11, 380, 463, 499, 436, 365, 268, 182, 36, 215, 491, 137, 175, 198, 458, 450, 772, 815, 664, 838, 3, 307, 306, 330, 902, 99, 954, 86, 506, 541, 97, 912, 876, 855, 612, 131, 844, 908, 466, 278, 731, 790, 927, 206, 98, 164, 806, 894, 420, 199, 127, 590, 467, 531, 771, 966, 596, 510, 341, 709, 4, 355, 363, 163, 746, 576, 781, 720, 56, 859, 314, 220, 879, 355, 786, 689, 433, 133, 95, 95, 147, 48, 665, 498, 204, 344, 261, 184, 26, 730, 626, 640, 166, 638, 429, 727, 734, 193, 69, 663, 673, 600, 907, 25, 21, 203, 223, 470, 337, 829, 66, 250, 610, 25, 269, 66, 864, 511, 341, 219, 606, 631, 17, 101, 804, 790, 968, 112, 215, 906, 585, 748, 594, 224, 574, 249, 80, 90, 335, 324, 4, 891, 852, 51, 952, 21, 555, 379, 698, 667, 881, 326, 732, 47, 867, 866, 349, 318, 363, 509, 23, 222, 158, 49, 937, 249, 929, 37, 91, 130, 467, 699, 61, 242, 414, 708, 130, 637, 812, 496, 369, 595, 457, 955, 134, 571, 85),928), 25)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.lengthOfLongestSubsequence(List(238, 717, 518, 445, 767, 289, 205, 849, 230, 267, 807, 184, 572, 659, 942, 158, 848, 151, 150, 659, 540, 595, 741, 811, 476, 820, 251, 822, 678, 545, 804, 231, 304, 271, 803, 222, 466, 278, 353, 672, 903, 330, 321, 961),861), 4)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.lengthOfLongestSubsequence(List(163, 461, 131, 267, 469, 811, 384, 749, 262, 988, 413, 876, 763, 461, 519, 777, 243, 248, 878, 170, 90, 801, 104, 340, 483, 216, 890, 125, 967, 695, 596, 264, 694, 780, 186, 60, 854, 571, 323, 281, 183, 695, 278, 761, 277, 793, 55, 276, 188, 827, 846, 673, 514, 3, 334, 817, 982, 942, 528, 735, 12, 968, 740, 54, 365, 392, 798, 443, 67, 793, 63, 371, 642, 258, 870, 783, 381, 921, 562, 750, 151, 963, 474, 998, 515, 903, 258, 183, 454, 679, 814, 888, 837, 822, 845, 75, 430, 663, 509, 941, 523, 415, 678, 242, 974, 894, 606, 541, 614, 76, 795, 374, 449, 13, 422, 292, 764, 640, 238, 411, 586, 495, 904, 773, 827, 810, 131, 771, 517, 11, 167, 350, 289, 7, 998, 566, 230, 662, 925, 429, 287, 435, 94, 344, 478, 538, 932, 518, 652, 650, 870, 124, 425, 611, 541, 347, 775, 541, 292, 93, 592, 809, 267, 567, 252, 705, 450, 531, 780, 295, 468, 946, 961, 515, 529, 772, 856, 64, 955, 850, 190, 153, 481, 438),100), 6)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.lengthOfLongestSubsequence(List(171, 608, 71, 229, 753, 460, 300, 639, 366, 819, 383, 890, 132, 261, 96, 273, 27, 928, 820, 359, 772, 640, 412, 841, 96, 847, 996, 952, 208, 593, 797, 153, 293, 264, 294, 496, 750, 710, 861, 411, 562, 343, 176, 752, 403, 239, 788, 583, 97, 803, 597, 972, 436, 653, 270, 651, 203, 756, 93, 397, 618, 266, 984, 972, 583, 501, 618, 4, 380, 338, 568, 495, 549, 752, 850, 872, 453, 959, 914, 805, 270, 271, 666, 685, 989, 197, 59, 214, 964, 725, 261, 255, 466, 776, 524, 140, 578, 619, 676, 818, 830, 427, 426, 585, 948, 949, 901, 545, 448, 382, 403, 644, 151, 842, 139, 597, 908, 196, 240, 73, 338, 759, 781, 549, 667, 730, 984, 267, 450, 905, 908, 856, 889, 784, 982, 471, 991, 993, 205, 103, 292, 46, 879, 737, 39, 133, 244, 820, 791, 907, 104, 413, 836, 417, 20, 569, 729, 983, 606, 330, 695, 831, 939, 483, 531, 405, 810, 365, 13, 687, 37, 296, 96, 749, 919, 200, 717, 668, 726, 972, 773, 747, 171, 473, 200, 86, 967, 424, 695, 475, 244, 535, 920, 518, 549, 622, 169, 736, 957, 229, 559, 180, 27, 802, 802, 730, 546, 209, 86, 227, 559, 288, 113, 656, 69, 604, 773, 346, 614, 92, 912, 896, 731, 499, 232, 616, 695, 101, 299, 492, 761, 45, 225, 975, 477, 19, 445, 673, 459, 414, 442, 848, 806, 370, 110, 629, 900, 954, 335, 688, 467, 950, 130, 127, 97, 780, 221, 529, 123, 277, 73, 617, 501, 383, 746, 304, 312, 752, 400, 472, 615, 727, 891, 137, 725, 904, 186, 867, 895, 143, 442, 998, 645, 958, 339, 315, 632, 152, 553, 584, 880, 645, 164, 697, 607, 227, 961, 735, 825, 353, 755, 83, 782, 723, 623, 549, 882, 978, 150, 695, 351, 635, 153, 687, 776, 455, 881, 829, 927, 789, 317, 290, 943, 475, 592, 336, 848, 618, 828, 249, 297, 644, 448, 479, 506, 323, 442, 84, 186, 956, 843, 653, 153, 185, 973, 230, 657, 146, 647, 120, 255, 182, 845, 631, 14, 622, 642, 650, 149, 769, 982, 467, 896, 825, 698, 458, 296, 775, 994, 681, 219, 331, 741, 267, 14, 142, 178, 321, 415, 721, 233, 631, 456, 213, 444, 181, 281, 121, 347, 144, 876, 535, 954, 53, 148, 933, 133, 403, 121, 666, 679, 523, 973, 246, 21, 202, 200, 285, 631, 869, 92, 33, 675, 678, 167, 418, 8, 812, 146, 433, 784, 983, 31, 581, 691, 750, 81, 937, 391, 129, 218, 131, 305, 132, 398, 495, 350, 250, 236, 724, 278, 979, 259, 304, 409, 619, 295, 659, 242, 552, 442, 95, 595, 204, 423, 515, 764, 80, 873, 54, 742, 548, 969, 287, 490, 867, 99, 743, 267, 199, 888, 216, 782, 352, 512, 516, 943, 305, 143, 556, 476, 891, 748, 508, 918, 764, 711, 561, 81, 726, 607, 923, 1000, 181, 602, 917, 33, 235, 247, 895, 293, 893, 790, 399, 567, 585, 927, 483, 781, 641, 505, 517, 420, 751, 153, 273, 297, 904, 823, 781, 451, 775, 966, 531, 161, 997, 641, 337, 995, 955, 757, 340, 793, 828, 74, 372, 395, 119, 138, 378, 972, 397, 421, 663, 411, 723, 514, 528, 173, 524, 28, 605, 193, 286, 598, 966, 540, 758, 871, 682, 997, 762, 410, 191, 11, 871, 902, 713, 298, 987, 52, 378, 960, 605, 614, 709, 538, 84, 360, 572, 844, 343, 834, 291, 129, 932, 166, 966, 725, 190, 412, 770, 966, 570, 628, 34, 220, 891, 130, 417, 44, 517, 522, 606, 189, 254, 901, 367, 556, 797, 355, 989, 376, 850, 826, 619, 597, 67, 778, 753, 770, 902, 320, 691, 261, 406, 372, 244, 941, 729, 84, 123, 296, 108, 111, 838, 9, 428, 215, 884, 686, 947, 110, 570, 881, 606, 450, 488, 495, 847, 733, 273, 255, 205, 831, 538, 59, 47, 479, 68, 903, 687, 272, 417, 114, 6, 874, 917, 212, 301, 127, 991, 731, 874, 884, 166, 440, 146),355), 18)
42
+ }
43
+
44
+ }
length_of_the_longest_valid_substring/.DS_Store ADDED
Binary file (6.15 kB). View file
 
length_of_the_longest_valid_substring/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 (longestValidSubstring \"cbaaaabc \" [ \"aaa \", \"cb \"])," 4 (longestValidSubstring "cbaaaabc" ["aaa","cb"]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestValidSubstring \"leetcode \" [ \"de \", \"le \", \"e \"])," 4 (longestValidSubstring "leetcode" ["de","le","e"]))
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
length_of_the_longest_valid_substring/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, longestValidSubstring("cbaaaabc", new ArrayList<>(Arrays.asList("aaa","cb"))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, longestValidSubstring("leetcode", new ArrayList<>(Arrays.asList("de","le","e"))));
19
+ }
20
+
21
+ }
length_of_the_longest_valid_substring/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2884,
3
+ "name": "length_of_the_longest_valid_substring",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/length-of-the-longest-valid-substring/",
6
+ "date": "1688860800000",
7
+ "task_description": "You are given a string `word` and an array of strings `forbidden`. A string is called **valid** if none of its substrings are present in `forbidden`. Return _the length of the **longest valid substring** of the string _`word`. A **substring** is a contiguous sequence of characters in a string, possibly empty. **Example 1:** ``` **Input:** word = \"cbaaaabc\", forbidden = [\"aaa\",\"cb\"] **Output:** 4 **Explanation:** There are 11 valid substrings in word: \"c\", \"b\", \"a\", \"ba\", \"aa\", \"bc\", \"baa\", \"aab\", \"ab\", \"abc\" and \"aabc\". The length of the longest valid substring is 4. It can be shown that all other substrings contain either \"aaa\" or \"cb\" as a substring. ``` **Example 2:** ``` **Input:** word = \"leetcode\", forbidden = [\"de\",\"le\",\"e\"] **Output:** 4 **Explanation:** There are 11 valid substrings in word: \"l\", \"t\", \"c\", \"o\", \"d\", \"tc\", \"co\", \"od\", \"tco\", \"cod\", and \"tcod\". The length of the longest valid substring is 4. It can be shown that all other substrings contain either \"de\", \"le\", or \"e\" as a substring. ``` **Constraints:** `1 <= word.length <= 105` `word` consists only of lowercase English letters. `1 <= forbidden.length <= 105` `1 <= forbidden[i].length <= 10` `forbidden[i]` consists only of lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "word = \"cbaaaabc\", forbidden = [\"aaa\",\"cb\"]",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "word = \"leetcode\", forbidden = [\"de\",\"le\",\"e\"]",
17
+ "output": "4 "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "longestValidSubstring :: String -> [String] -> Int\nlongestValidSubstring word forbidden ",
22
+ "ocaml_template": "let longestValidSubstring (word: string) (forbidden: string list) : int = ",
23
+ "scala_template": "def longestValidSubstring(word: String,forbidden: List[String]): Int = { \n \n}",
24
+ "java_template": "public static int longestValidSubstring(String word, List<String> forbidden) {\n\n}",
25
+ "python_template": "class Solution(object):\n def longestValidSubstring(self, word, forbidden):\n \"\"\"\n :type word: str\n :type forbidden: List[str]\n :rtype: int\n \"\"\"\n "
26
+ }
length_of_the_longest_valid_substring/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 (longestValidSubstring "cbaaaabc" ["aaa";"cb"])
12
+
13
+ let test2 _ = assert_equal 4 (longestValidSubstring "leetcode" ["de";"le";"e"])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for longestValidSubstring" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
length_of_the_longest_valid_substring/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestValidSubstring("cbaaaabc",["aaa","cb"]), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestValidSubstring("leetcode",["de","le","e"]), 4)
10
+ }
11
+
12
+ }
lexicographically_minimum_string_after_removing_stars/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ clearStars :: String -> String
7
+ clearStars s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (clearStars \"aaba* \")," "aab" (clearStars "aaba*"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (clearStars \"abc \")," "abc" (clearStars "abc"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (clearStars \"em*wg*f**ybr*l*pab*qibci**lb*a*iem**fa*hdovwy*azsxhmnldzu**vy*chsph**mrpcspuiykrgeevj*n***c* \")," "wyrpqiilimhovwyzsxhmnlzuvyhspmrpspuiykrvjn" (clearStars "em*wg*f**ybr*l*pab*qibci**lb*a*iem**fa*hdovwy*azsxhmnldzu**vy*chsph**mrpcspuiykrgeevj*n***c*"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (clearStars \"***v**tn**yz*ue*posifv**x*b*p****vskqa*zt*s***uo*nt*iaod**d \")," "zvxvztutiod" (clearStars "***v**tn**yz*ue*posifv**x*b*p****vskqa*zt*s***uo*nt*iaod**d"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (clearStars \"*eu*i*crro****pdthvkhfmb*cgrqdimoujhvszay**wjwo \")," "updthvkhfmgrqdimoujhvszywjwo" (clearStars "*eu*i*crro****pdthvkhfmb*cgrqdimoujhvszay**wjwo"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (clearStars \"ydmb*****vxtav* \")," "vxtv" (clearStars "ydmb*****vxtav*"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (clearStars \"ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx \")," "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx" (clearStars "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx"))
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