DatasetRepo commited on
Commit
21bef0d
·
verified ·
1 Parent(s): a1f68ed

89faea376bbae1bbc08075e7ee258df9dca329683f3b7ec070d414da7b5e4867

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 +6 -0
  2. longest_increasing_subsequence_ii/ocaml_tests/main.ml +29 -0
  3. longest_increasing_subsequence_ii/scala_tests/MySuite.scala +16 -0
  4. longest_nice_subarray/.DS_Store +0 -0
  5. longest_nice_subarray/haskell_tests/Main.hs +24 -0
  6. longest_nice_subarray/java_tests/Main.java +21 -0
  7. longest_nice_subarray/meta.json +0 -0
  8. longest_nice_subarray/ocaml_tests/main.ml +26 -0
  9. longest_nice_subarray/scala_tests/MySuite.scala +12 -0
  10. longest_non_decreasing_subarray_from_two_arrays/haskell_tests/Main.hs +3 -0
  11. longest_non_decreasing_subarray_from_two_arrays/java_tests/Main.java +25 -0
  12. longest_non_decreasing_subarray_from_two_arrays/meta.json +3 -0
  13. longest_non_decreasing_subarray_from_two_arrays/ocaml_tests/main.ml +0 -0
  14. longest_non_decreasing_subarray_from_two_arrays/scala_tests/MySuite.scala +0 -0
  15. longest_palindrome_by_concatenating_two_letter_words/.DS_Store +0 -0
  16. longest_palindrome_by_concatenating_two_letter_words/haskell_tests/Main.hs +27 -0
  17. longest_palindrome_by_concatenating_two_letter_words/java_tests/Main.java +25 -0
  18. longest_palindrome_by_concatenating_two_letter_words/meta.json +3 -0
  19. longest_palindrome_by_concatenating_two_letter_words/ocaml_tests/main.ml +29 -0
  20. longest_palindrome_by_concatenating_two_letter_words/scala_tests/MySuite.scala +16 -0
  21. longest_palindromic_subsequence_after_at_most_k_operations/haskell_tests/Main.hs +45 -0
  22. longest_palindromic_subsequence_after_at_most_k_operations/java_tests/Main.java +21 -0
  23. longest_palindromic_subsequence_after_at_most_k_operations/meta.json +97 -0
  24. longest_palindromic_subsequence_after_at_most_k_operations/ocaml_tests/main.ml +50 -0
  25. longest_palindromic_subsequence_after_at_most_k_operations/scala_tests/MySuite.scala +44 -0
  26. longest_path_with_different_adjacent_characters/haskell_tests/Main.hs +0 -0
  27. longest_path_with_different_adjacent_characters/java_tests/Main.java +21 -0
  28. longest_path_with_different_adjacent_characters/meta.json +3 -0
  29. longest_path_with_different_adjacent_characters/ocaml_tests/main.ml +0 -0
  30. longest_path_with_different_adjacent_characters/scala_tests/MySuite.scala +0 -0
  31. longest_special_path/haskell_tests/Main.hs +0 -0
  32. longest_special_path/java_tests/Main.java +21 -0
  33. longest_special_path/meta.json +3 -0
  34. longest_special_path/ocaml_tests/main.ml +0 -0
  35. longest_special_path/scala_tests/MySuite.scala +0 -0
  36. longest_special_path_ii/haskell_tests/Main.hs +0 -0
  37. longest_special_path_ii/java_tests/Main.java +21 -0
  38. longest_special_path_ii/meta.json +3 -0
  39. longest_special_path_ii/ocaml_tests/main.ml +0 -0
  40. longest_special_path_ii/scala_tests/MySuite.scala +0 -0
  41. longest_square_streak_in_an_array/.DS_Store +0 -0
  42. longest_square_streak_in_an_array/haskell_tests/Main.hs +24 -0
  43. longest_square_streak_in_an_array/java_tests/Main.java +21 -0
  44. longest_square_streak_in_an_array/meta.json +0 -0
  45. longest_square_streak_in_an_array/ocaml_tests/main.ml +26 -0
  46. longest_square_streak_in_an_array/scala_tests/MySuite.scala +12 -0
  47. longest_strictly_increasing_or_strictly_decreasing_subarray/haskell_tests/Main.hs +44 -0
  48. longest_strictly_increasing_or_strictly_decreasing_subarray/java_tests/Main.java +24 -0
  49. longest_strictly_increasing_or_strictly_decreasing_subarray/meta.json +225 -0
  50. longest_strictly_increasing_or_strictly_decreasing_subarray/ocaml_tests/main.ml +45 -0
.gitattributes CHANGED
@@ -145,3 +145,9 @@ largest_element_in_an_array_after_merge_operations/meta.json filter=lfs diff=lfs
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
 
 
 
 
 
 
 
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
148
+ longest_non_decreasing_subarray_from_two_arrays/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
149
+ longest_non_decreasing_subarray_from_two_arrays/meta.json filter=lfs diff=lfs merge=lfs -text
150
+ longest_palindrome_by_concatenating_two_letter_words/meta.json filter=lfs diff=lfs merge=lfs -text
151
+ longest_path_with_different_adjacent_characters/meta.json filter=lfs diff=lfs merge=lfs -text
152
+ longest_special_path/meta.json filter=lfs diff=lfs merge=lfs -text
153
+ longest_special_path_ii/meta.json filter=lfs diff=lfs merge=lfs -text
longest_increasing_subsequence_ii/ocaml_tests/main.ml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 5 (lengthOfLIS [4;2;1;4;3;4;5;8;15] 3)
12
+
13
+ let test2 _ = assert_equal 4 (lengthOfLIS [7;4;5;1;8;12;4;7] 5)
14
+
15
+ let test3 _ = assert_equal 1 (lengthOfLIS [1;5] 1)
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for lengthOfLIS" >::: [
20
+
21
+ "test1" >:: test1;
22
+ "test2" >:: test2;
23
+ "test3" >:: test3;
24
+ ]
25
+
26
+
27
+ (* Running the tests *)
28
+ let () = run_test_tt_main suite
29
+ end
longest_increasing_subsequence_ii/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.lengthOfLIS(List(4,2,1,4,3,4,5,8,15),3), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.lengthOfLIS(List(7,4,5,1,8,12,4,7),5), 4)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.lengthOfLIS(List(1,5),1), 1)
14
+ }
15
+
16
+ }
longest_nice_subarray/.DS_Store ADDED
Binary file (6.15 kB). View file
 
longest_nice_subarray/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 (longestNiceSubarray [1,3,8,48,10])," 3 (longestNiceSubarray [1,3,8,48,10]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestNiceSubarray [3,1,5,11,13])," 1 (longestNiceSubarray [3,1,5,11,13]))
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
longest_nice_subarray/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, longestNiceSubarray(new ArrayList<>(Arrays.asList(1,3,8,48,10))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, longestNiceSubarray(new ArrayList<>(Arrays.asList(3,1,5,11,13))));
19
+ }
20
+
21
+ }
longest_nice_subarray/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
longest_nice_subarray/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (longestNiceSubarray [1;3;8;48;10])
12
+
13
+ let test2 _ = assert_equal 1 (longestNiceSubarray [3;1;5;11;13])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for longestNiceSubarray" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
longest_nice_subarray/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestNiceSubarray(List(1,3,8,48,10)), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestNiceSubarray(List(3,1,5,11,13)), 1)
10
+ }
11
+
12
+ }
longest_non_decreasing_subarray_from_two_arrays/haskell_tests/Main.hs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:132cf5c9466e8e2b424926a3d2db7991a0e72be20bd11e891d5cf256f4a58f3d
3
+ size 15389920
longest_non_decreasing_subarray_from_two_arrays/java_tests/Main.java ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(2, maxNonDecreasingLength(new ArrayList<>(Arrays.asList(2,3,1)), new ArrayList<>(Arrays.asList(1,2,1))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, maxNonDecreasingLength(new ArrayList<>(Arrays.asList(1,3,2,1)), new ArrayList<>(Arrays.asList(2,2,3,4))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(2, maxNonDecreasingLength(new ArrayList<>(Arrays.asList(1,1)), new ArrayList<>(Arrays.asList(2,2))));
23
+ }
24
+
25
+ }
longest_non_decreasing_subarray_from_two_arrays/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6098f91f3cfb93e5cd7c53ca596ca04b9a4e577f474a2337192fb34578dc4e59
3
+ size 35722768
longest_non_decreasing_subarray_from_two_arrays/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
longest_non_decreasing_subarray_from_two_arrays/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
longest_palindrome_by_concatenating_two_letter_words/.DS_Store ADDED
Binary file (6.15 kB). View file
 
longest_palindrome_by_concatenating_two_letter_words/haskell_tests/Main.hs ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (longestPalindrome [ \"lc \", \"cl \", \"gg \"])," 6 (longestPalindrome ["lc","cl","gg"]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestPalindrome [ \"ab \", \"ty \", \"yt \", \"lc \", \"cl \", \"ab \"])," 8 (longestPalindrome ["ab","ty","yt","lc","cl","ab"]))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (longestPalindrome [ \"cc \", \"ll \", \"xx \"])," 2 (longestPalindrome ["cc","ll","xx"]))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
longest_palindrome_by_concatenating_two_letter_words/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, longestPalindrome(new ArrayList<>(Arrays.asList("lc","cl","gg"))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(8, longestPalindrome(new ArrayList<>(Arrays.asList("ab","ty","yt","lc","cl","ab"))));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(2, longestPalindrome(new ArrayList<>(Arrays.asList("cc","ll","xx"))));
23
+ }
24
+
25
+ }
longest_palindrome_by_concatenating_two_letter_words/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:131b6c27ab387fc63aff839d778b4fede127727da1b15d827f68cc5cb7eeaf47
3
+ size 13617758
longest_palindrome_by_concatenating_two_letter_words/ocaml_tests/main.ml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 6 (longestPalindrome ["lc";"cl";"gg"])
12
+
13
+ let test2 _ = assert_equal 8 (longestPalindrome ["ab";"ty";"yt";"lc";"cl";"ab"])
14
+
15
+ let test3 _ = assert_equal 2 (longestPalindrome ["cc";"ll";"xx"])
16
+
17
+
18
+ (* Grouping test cases *)
19
+ let suite = "Test Suite for longestPalindrome" >::: [
20
+
21
+ "test1" >:: test1;
22
+ "test2" >:: test2;
23
+ "test3" >:: test3;
24
+ ]
25
+
26
+
27
+ (* Running the tests *)
28
+ let () = run_test_tt_main suite
29
+ end
longest_palindrome_by_concatenating_two_letter_words/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestPalindrome(List("lc","cl","gg")), 6)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestPalindrome(List("ab","ty","yt","lc","cl","ab")), 8)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.longestPalindrome(List("cc","ll","xx")), 2)
14
+ }
15
+
16
+ }
longest_palindromic_subsequence_after_at_most_k_operations/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 (longestPalindromicSubsequence \"abced \" 2)," 3 (longestPalindromicSubsequence "abced" 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestPalindromicSubsequence \" aaazzz \" 4)," 6 (longestPalindromicSubsequence " aaazzz " 4))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (longestPalindromicSubsequence \"bgngurzzgzmenzpemgldtnkwtengymnfuwguviil \" 4)," 19 (longestPalindromicSubsequence "bgngurzzgzmenzpemgldtnkwtengymnfuwguviil" 4))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (longestPalindromicSubsequence \"mxfldfmfceqnmdnxtyzxpxacyetdefktaulnwmwwinilyosxhjnhfymrcuteiytwowvzafsrzbyeeohikxjzpeshqvbyzfwrtddbsmuvmdkaojytuvmubtkmsrptizalwocnyyxtfjhskamenbulemyblguusw \" 10)," 67 (longestPalindromicSubsequence "mxfldfmfceqnmdnxtyzxpxacyetdefktaulnwmwwinilyosxhjnhfymrcuteiytwowvzafsrzbyeeohikxjzpeshqvbyzfwrtddbsmuvmdkaojytuvmubtkmsrptizalwocnyyxtfjhskamenbulemyblguusw" 10))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (longestPalindromicSubsequence \"rvxljjsrupvrskplidkerrpabdpfilnpjobtpaydksagivihssbswrmuodpjwitvbmkbcousxzvbzywpqtjhr \" 84)," 67 (longestPalindromicSubsequence "rvxljjsrupvrskplidkerrpabdpfilnpjobtpaydksagivihssbswrmuodpjwitvbmkbcousxzvbzywpqtjhr" 84))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (longestPalindromicSubsequence \"mwmtldzgbmapsnkjafwnrotwuimbfkbzyenglpqnahlacsstnwoxnkgwqvkbkfdftqoentbbykvikokqhtidlflsqwjuleeuqwnhfgdibfjyfcbvmvwuqsfvttocsrcypg \" 115)," 101 (longestPalindromicSubsequence "mwmtldzgbmapsnkjafwnrotwuimbfkbzyenglpqnahlacsstnwoxnkgwqvkbkfdftqoentbbykvikokqhtidlflsqwjuleeuqwnhfgdibfjyfcbvmvwuqsfvttocsrcypg" 115))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (longestPalindromicSubsequence \"mgaevjqdbrbbgvrirlznfxncdkgbnhjkqpkusyxwsprerypomqbvhiyxtxvoukpgsfxszjjeqebntfsvdhipvfczwdbcsgujgspvuglgrrpqrzenayndiijjzomdbpcktcfmypsndhcndoltmalwvifypuqqyci \" 89)," 111 (longestPalindromicSubsequence "mgaevjqdbrbbgvrirlznfxncdkgbnhjkqpkusyxwsprerypomqbvhiyxtxvoukpgsfxszjjeqebntfsvdhipvfczwdbcsgujgspvuglgrrpqrzenayndiijjzomdbpcktcfmypsndhcndoltmalwvifypuqqyci" 89))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (longestPalindromicSubsequence \"bbdbxwmzswununfmmnjddrpddgldjztxzgnmmhnnyqyqmefguektdnsmzyyrbweqbsmyjumvr \" 141)," 67 (longestPalindromicSubsequence "bbdbxwmzswununfmmnjddrpddgldjztxzgnmmhnnyqyqmefguektdnsmzyyrbweqbsmyjumvr" 141))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (longestPalindromicSubsequence \"mjtqkwvoaqnrbcaxmfltxgxklslfgljvclzkixescuhylueemymirpinpzstcsjogrquxwqxvqzbcvysjhxaigzcxlsgjtujicjjowfprubrfjiewbmhg \" 3)," 44 (longestPalindromicSubsequence "mjtqkwvoaqnrbcaxmfltxgxklslfgljvclzkixescuhylueemymirpinpzstcsjogrquxwqxvqzbcvysjhxaigzcxlsgjtujicjjowfprubrfjiewbmhg" 3))
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
longest_palindromic_subsequence_after_at_most_k_operations/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, longestPalindromicSubsequence("abced", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(6, longestPalindromicSubsequence(" aaazzz ", 4));
19
+ }
20
+
21
+ }
longest_palindromic_subsequence_after_at_most_k_operations/meta.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3786,
3
+ "name": "longest_palindromic_subsequence_after_at_most_k_operations",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/longest-palindromic-subsequence-after-at-most-k-operations/",
6
+ "date": "2025-02-23 00:00:00",
7
+ "task_description": "You are given a string `s` and an integer `k`. In one operation, you can replace the character at any position with the next or previous letter in the alphabet (wrapping around so that `'a'` is after `'z'`). For example, replacing `'a'` with the next letter results in `'b'`, and replacing `'a'` with the previous letter results in `'z'`. Similarly, replacing `'z'` with the next letter results in `'a'`, and replacing `'z'` with the previous letter results in `'y'`. Return the length of the **longest palindromic subsequence** of `s` that can be obtained after performing **at most** `k` operations. **Example 1:** **Input:** s = \"abced\", k = 2 **Output:** 3 **Explanation:** Replace `s[1]` with the next letter, and `s` becomes `\"acced\"`. Replace `s[4]` with the previous letter, and `s` becomes `\"accec\"`. The subsequence `\"ccc\"` forms a palindrome of length 3, which is the maximum. **Example 2:** **Input:** s = \"aaazzz\", k = 4 **Output:** 6 **Explanation:** Replace `s[0]` with the previous letter, and `s` becomes `\"zaazzz\"`. Replace `s[4]` with the next letter, and `s` becomes `\"zaazaz\"`. Replace `s[3]` with the next letter, and `s` becomes `\"zaaaaz\"`. The entire string forms a palindrome of length 6. **Constraints:** `1 <= s.length <= 200` `1 <= k <= 200` `s` consists of only lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"abced\", k = 2",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \" aaazzz \", k = 4",
17
+ "output": "6 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"bgngurzzgzmenzpemgldtnkwtengymnfuwguviil\"",
24
+ 4
25
+ ],
26
+ "output": 19
27
+ },
28
+ {
29
+ "input": [
30
+ "\"mxfldfmfceqnmdnxtyzxpxacyetdefktaulnwmwwinilyosxhjnhfymrcuteiytwowvzafsrzbyeeohikxjzpeshqvbyzfwrtddbsmuvmdkaojytuvmubtkmsrptizalwocnyyxtfjhskamenbulemyblguusw\"",
31
+ 10
32
+ ],
33
+ "output": 67
34
+ },
35
+ {
36
+ "input": [
37
+ "\"rvxljjsrupvrskplidkerrpabdpfilnpjobtpaydksagivihssbswrmuodpjwitvbmkbcousxzvbzywpqtjhr\"",
38
+ 84
39
+ ],
40
+ "output": 67
41
+ },
42
+ {
43
+ "input": [
44
+ "\"mwmtldzgbmapsnkjafwnrotwuimbfkbzyenglpqnahlacsstnwoxnkgwqvkbkfdftqoentbbykvikokqhtidlflsqwjuleeuqwnhfgdibfjyfcbvmvwuqsfvttocsrcypg\"",
45
+ 115
46
+ ],
47
+ "output": 101
48
+ },
49
+ {
50
+ "input": [
51
+ "\"mgaevjqdbrbbgvrirlznfxncdkgbnhjkqpkusyxwsprerypomqbvhiyxtxvoukpgsfxszjjeqebntfsvdhipvfczwdbcsgujgspvuglgrrpqrzenayndiijjzomdbpcktcfmypsndhcndoltmalwvifypuqqyci\"",
52
+ 89
53
+ ],
54
+ "output": 111
55
+ },
56
+ {
57
+ "input": [
58
+ "\"bbdbxwmzswununfmmnjddrpddgldjztxzgnmmhnnyqyqmefguektdnsmzyyrbweqbsmyjumvr\"",
59
+ 141
60
+ ],
61
+ "output": 67
62
+ },
63
+ {
64
+ "input": [
65
+ "\"mjtqkwvoaqnrbcaxmfltxgxklslfgljvclzkixescuhylueemymirpinpzstcsjogrquxwqxvqzbcvysjhxaigzcxlsgjtujicjjowfprubrfjiewbmhg\"",
66
+ 3
67
+ ],
68
+ "output": 44
69
+ },
70
+ {
71
+ "input": [
72
+ "\"bsyoxkfxelibwfjpwybtdmtlgfxdpnmbjggdysqxccacehdvilwacdtvpfokojyezqod\"",
73
+ 197
74
+ ],
75
+ "output": 67
76
+ },
77
+ {
78
+ "input": [
79
+ "qvjpxvmggdghbtwtdfkrvfeiydhphqmghfzyoazoepytwwdiedzpzva",
80
+ 7
81
+ ],
82
+ "output": 26
83
+ },
84
+ {
85
+ "input": [
86
+ "lzxmrntypqvntucnojvfmjqsoygxozzusrokjjlngbaivkyxznjiojqmcbisazkfnzrsegsavlnwfwaok",
87
+ 110
88
+ ],
89
+ "output": 70
90
+ }
91
+ ],
92
+ "haskell_template": "longestPalindromicSubsequence :: String -> Int -> Int\nlongestPalindromicSubsequence s k ",
93
+ "ocaml_template": "let longestPalindromicSubsequence (s: string) (k: int) : int = ",
94
+ "scala_template": "def longestPalindromicSubsequence(s: String,k: Int): Int = { \n \n}",
95
+ "java_template": "class Solution {\n public int longestPalindromicSubsequence(String s, int k) {\n \n }\n}",
96
+ "python_template": "class Solution(object):\n def longestPalindromicSubsequence(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: int\n \"\"\"\n "
97
+ }
longest_palindromic_subsequence_after_at_most_k_operations/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 (longestPalindromicSubsequence "abced" 2)
12
+
13
+ let test2 _ = assert_equal 6 (longestPalindromicSubsequence " aaazzz " 4)
14
+
15
+ let test3 _ = assert_equal 19 (longestPalindromicSubsequence "bgngurzzgzmenzpemgldtnkwtengymnfuwguviil" 4)
16
+
17
+ let test4 _ = assert_equal 67 (longestPalindromicSubsequence "mxfldfmfceqnmdnxtyzxpxacyetdefktaulnwmwwinilyosxhjnhfymrcuteiytwowvzafsrzbyeeohikxjzpeshqvbyzfwrtddbsmuvmdkaojytuvmubtkmsrptizalwocnyyxtfjhskamenbulemyblguusw" 10)
18
+
19
+ let test5 _ = assert_equal 67 (longestPalindromicSubsequence "rvxljjsrupvrskplidkerrpabdpfilnpjobtpaydksagivihssbswrmuodpjwitvbmkbcousxzvbzywpqtjhr" 84)
20
+
21
+ let test6 _ = assert_equal 101 (longestPalindromicSubsequence "mwmtldzgbmapsnkjafwnrotwuimbfkbzyenglpqnahlacsstnwoxnkgwqvkbkfdftqoentbbykvikokqhtidlflsqwjuleeuqwnhfgdibfjyfcbvmvwuqsfvttocsrcypg" 115)
22
+
23
+ let test7 _ = assert_equal 111 (longestPalindromicSubsequence "mgaevjqdbrbbgvrirlznfxncdkgbnhjkqpkusyxwsprerypomqbvhiyxtxvoukpgsfxszjjeqebntfsvdhipvfczwdbcsgujgspvuglgrrpqrzenayndiijjzomdbpcktcfmypsndhcndoltmalwvifypuqqyci" 89)
24
+
25
+ let test8 _ = assert_equal 67 (longestPalindromicSubsequence "bbdbxwmzswununfmmnjddrpddgldjztxzgnmmhnnyqyqmefguektdnsmzyyrbweqbsmyjumvr" 141)
26
+
27
+ let test9 _ = assert_equal 44 (longestPalindromicSubsequence "mjtqkwvoaqnrbcaxmfltxgxklslfgljvclzkixescuhylueemymirpinpzstcsjogrquxwqxvqzbcvysjhxaigzcxlsgjtujicjjowfprubrfjiewbmhg" 3)
28
+
29
+ let test10 _ = assert_equal 67 (longestPalindromicSubsequence "bsyoxkfxelibwfjpwybtdmtlgfxdpnmbjggdysqxccacehdvilwacdtvpfokojyezqod" 197)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for longestPalindromicSubsequence" >::: [
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
longest_palindromic_subsequence_after_at_most_k_operations/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestPalindromicSubsequence("abced",2), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestPalindromicSubsequence(4), 6)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.longestPalindromicSubsequence("bgngurzzgzmenzpemgldtnkwtengymnfuwguviil",4), 19)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.longestPalindromicSubsequence("mxfldfmfceqnmdnxtyzxpxacyetdefktaulnwmwwinilyosxhjnhfymrcuteiytwowvzafsrzbyeeohikxjzpeshqvbyzfwrtddbsmuvmdkaojytuvmubtkmsrptizalwocnyyxtfjhskamenbulemyblguusw",10), 67)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.longestPalindromicSubsequence("rvxljjsrupvrskplidkerrpabdpfilnpjobtpaydksagivihssbswrmuodpjwitvbmkbcousxzvbzywpqtjhr",84), 67)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.longestPalindromicSubsequence("mwmtldzgbmapsnkjafwnrotwuimbfkbzyenglpqnahlacsstnwoxnkgwqvkbkfdftqoentbbykvikokqhtidlflsqwjuleeuqwnhfgdibfjyfcbvmvwuqsfvttocsrcypg",115), 101)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.longestPalindromicSubsequence("mgaevjqdbrbbgvrirlznfxncdkgbnhjkqpkusyxwsprerypomqbvhiyxtxvoukpgsfxszjjeqebntfsvdhipvfczwdbcsgujgspvuglgrrpqrzenayndiijjzomdbpcktcfmypsndhcndoltmalwvifypuqqyci",89), 111)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.longestPalindromicSubsequence("bbdbxwmzswununfmmnjddrpddgldjztxzgnmmhnnyqyqmefguektdnsmzyyrbweqbsmyjumvr",141), 67)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.longestPalindromicSubsequence("mjtqkwvoaqnrbcaxmfltxgxklslfgljvclzkixescuhylueemymirpinpzstcsjogrquxwqxvqzbcvysjhxaigzcxlsgjtujicjjowfprubrfjiewbmhg",3), 44)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.longestPalindromicSubsequence("bsyoxkfxelibwfjpwybtdmtlgfxdpnmbjggdysqxccacehdvilwacdtvpfokojyezqod",197), 67)
42
+ }
43
+
44
+ }
longest_path_with_different_adjacent_characters/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
longest_path_with_different_adjacent_characters/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, longestPath(new ArrayList<>(Arrays.asList(-1,0,0,1,1,2)), "abacbe"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(3, longestPath(new ArrayList<>(Arrays.asList(-1,0,0,0)), "aabc"));
19
+ }
20
+
21
+ }
longest_path_with_different_adjacent_characters/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1ca92b8911fb5a5c403e556dea49288ef3ca6cd930e839332495551dfe05c85
3
+ size 15017359
longest_path_with_different_adjacent_characters/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
longest_path_with_different_adjacent_characters/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_path/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_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(new ArrayList<>(Arrays.asList(6,2)), longestSpecialPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1,2)),new ArrayList<>(Arrays.asList(1,2,3)),new ArrayList<>(Arrays.asList(1,3,5)),new ArrayList<>(Arrays.asList(1,4,4)),new ArrayList<>(Arrays.asList(2,5,6)))), new ArrayList<>(Arrays.asList(2,1,2,1,3,1))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(0,1)), longestSpecialPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,0,8)))), new ArrayList<>(Arrays.asList(2,2))));
19
+ }
20
+
21
+ }
longest_special_path/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a529597d88310bce690d040c4c3043eb71df67fbe40395f98c98fa6b20b4ed3b
3
+ size 39432557
longest_special_path/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_path/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_path_ii/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_path_ii/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(new ArrayList<>(Arrays.asList(9,3)), longestSpecialPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,1,1)),new ArrayList<>(Arrays.asList(1,2,3)),new ArrayList<>(Arrays.asList(1,3,1)),new ArrayList<>(Arrays.asList(2,4,6)),new ArrayList<>(Arrays.asList(4,7,2)),new ArrayList<>(Arrays.asList(3,5,2)),new ArrayList<>(Arrays.asList(3,6,5)),new ArrayList<>(Arrays.asList(6,8,3)))), new ArrayList<>(Arrays.asList(1,1,0,3,1,2,1,1,0))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(new ArrayList<>(Arrays.asList(5,2)), longestSpecialPath(new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,0,3)),new ArrayList<>(Arrays.asList(0,2,4)),new ArrayList<>(Arrays.asList(0,3,5)))), new ArrayList<>(Arrays.asList(1,1,0,2))));
19
+ }
20
+
21
+ }
longest_special_path_ii/meta.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08604ee30447c989a9e23edc4760128b0be9a391e511aa3d810cc8fa07d53cdd
3
+ size 34731201
longest_special_path_ii/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
longest_special_path_ii/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
longest_square_streak_in_an_array/.DS_Store ADDED
Binary file (6.15 kB). View file
 
longest_square_streak_in_an_array/haskell_tests/Main.hs ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+
7
+ --Program end
8
+
9
+ -- Test cases
10
+
11
+ test1 :: Test
12
+ test1 = TestCase (assertEqual "for (longestSquareStreak [4,3,6,16,8,2])," 3 (longestSquareStreak [4,3,6,16,8,2]))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestSquareStreak [2,3,5,6,7])," (-1) (longestSquareStreak [2,3,5,6,7]))
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
longest_square_streak_in_an_array/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(3, longestSquareStreak(new ArrayList<>(Arrays.asList(4,3,6,16,8,2))));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(-1, longestSquareStreak(new ArrayList<>(Arrays.asList(2,3,5,6,7))));
19
+ }
20
+
21
+ }
longest_square_streak_in_an_array/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
longest_square_streak_in_an_array/ocaml_tests/main.ml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+
7
+ (* Program end *)
8
+
9
+ (* Test cases *)
10
+
11
+ let test1 _ = assert_equal 3 (longestSquareStreak [4;3;6;16;8;2])
12
+
13
+ let test2 _ = assert_equal (-1) (longestSquareStreak [2;3;5;6;7])
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for longestSquareStreak" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
longest_square_streak_in_an_array/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestSquareStreak(List(4,3,6,16,8,2)), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestSquareStreak(List(2,3,5,6,7)), -1)
10
+ }
11
+
12
+ }
longest_strictly_increasing_or_strictly_decreasing_subarray/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ longestMonotonicSubarray :: [Int] -> Int
7
+ longestMonotonicSubarray nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (longestMonotonicSubarray [1,4,3,3,2])," 2 (longestMonotonicSubarray [1,4,3,3,2]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (longestMonotonicSubarray [3,3,3,3])," 1 (longestMonotonicSubarray [3,3,3,3]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (longestMonotonicSubarray [3,2,1])," 3 (longestMonotonicSubarray [3,2,1]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (longestMonotonicSubarray [17, 11, 42, 20, 14, 23, 15, 4, 3, 27, 18, 12, 47, 36, 39, 36, 7, 4, 18, 15, 32, 7, 7, 19, 5, 31, 16, 37, 15, 19, 26, 17, 19, 42, 47, 47, 33])," 4 (longestMonotonicSubarray [17, 11, 42, 20, 14, 23, 15, 4, 3, 27, 18, 12, 47, 36, 39, 36, 7, 4, 18, 15, 32, 7, 7, 19, 5, 31, 16, 37, 15, 19, 26, 17, 19, 42, 47, 47, 33]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (longestMonotonicSubarray [4, 41, 47, 46, 12, 46, 22, 9, 27, 11, 41, 47, 7, 21, 6, 35, 48, 47, 39, 30, 12, 50, 36, 16, 36, 23, 3, 34, 21, 4, 48, 11, 22, 13, 27, 40, 47, 46, 20, 3, 4, 46, 13, 50, 8, 6])," 5 (longestMonotonicSubarray [4, 41, 47, 46, 12, 46, 22, 9, 27, 11, 41, 47, 7, 21, 6, 35, 48, 47, 39, 30, 12, 50, 36, 16, 36, 23, 3, 34, 21, 4, 48, 11, 22, 13, 27, 40, 47, 46, 20, 3, 4, 46, 13, 50, 8, 6]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (longestMonotonicSubarray [10, 50, 10, 10, 12, 48, 21, 5, 7, 23, 37, 29, 15, 23, 28])," 4 (longestMonotonicSubarray [10, 50, 10, 10, 12, 48, 21, 5, 7, 23, 37, 29, 15, 23, 28]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (longestMonotonicSubarray [32, 6, 23, 12, 49, 23, 29, 33, 47, 48, 7, 42, 10, 13, 2, 8, 11, 34, 7, 3, 34, 35, 10, 35, 23, 29, 12, 48, 41, 10, 40, 30])," 5 (longestMonotonicSubarray [32, 6, 23, 12, 49, 23, 29, 33, 47, 48, 7, 42, 10, 13, 2, 8, 11, 34, 7, 3, 34, 35, 10, 35, 23, 29, 12, 48, 41, 10, 40, 30]))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (longestMonotonicSubarray [17, 29, 10, 39, 14, 18, 12, 3, 21, 49, 16, 42, 7, 13, 17, 38, 2, 9, 42, 22, 8, 47, 1, 27, 41, 16, 33, 23, 16, 15, 21, 22, 14, 38, 29, 28, 30, 15])," 4 (longestMonotonicSubarray [17, 29, 10, 39, 14, 18, 12, 3, 21, 49, 16, 42, 7, 13, 17, 38, 2, 9, 42, 22, 8, 47, 1, 27, 41, 16, 33, 23, 16, 15, 21, 22, 14, 38, 29, 28, 30, 15]))
36
+
37
+
38
+ -- Grouping test cases
39
+ tests :: Test
40
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7]
41
+
42
+ -- Running the tests
43
+ main :: IO Counts
44
+ main = runTestTT tests
longest_strictly_increasing_or_strictly_decreasing_subarray/java_tests/Main.java ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ public class Main {
7
+ //Program start
8
+
9
+ //Program end
10
+
11
+ @Test
12
+ public void test1() {
13
+ assertEquals(2, longestMonotonicSubarray(Arrays.asList(1,4,3,3,2)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(1, longestMonotonicSubarray(Arrays.asList(3,3,3,3)));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals(3, longestMonotonicSubarray(Arrays.asList(3,2,1)));
22
+ }
23
+
24
+ }
longest_strictly_increasing_or_strictly_decreasing_subarray/meta.json ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3372,
3
+ "name": "longest_strictly_increasing_or_strictly_decreasing_subarray",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/",
6
+ "date": "2024-03-31 00:00:00",
7
+ "task_description": "You are given an array of integers `nums`. Return _the length of the **longest** subarray of _`nums`_ which is either **strictly increasing** or **strictly decreasing**_. **Example 1:** **Input:** nums = [1,4,3,3,2] **Output:** 2 **Explanation:** The strictly increasing subarrays of `nums` are `[1]`, `[2]`, `[3]`, `[3]`, `[4]`, and `[1,4]`. The strictly decreasing subarrays of `nums` are `[1]`, `[2]`, `[3]`, `[3]`, `[4]`, `[3,2]`, and `[4,3]`. Hence, we return `2`. **Example 2:** **Input:** nums = [3,3,3,3] **Output:** 1 **Explanation:** The strictly increasing subarrays of `nums` are `[3]`, `[3]`, `[3]`, and `[3]`. The strictly decreasing subarrays of `nums` are `[3]`, `[3]`, `[3]`, and `[3]`. Hence, we return `1`. **Example 3:** **Input:** nums = [3,2,1] **Output:** 3 **Explanation:** The strictly increasing subarrays of `nums` are `[3]`, `[2]`, and `[1]`. The strictly decreasing subarrays of `nums` are `[3]`, `[2]`, `[1]`, `[3,2]`, `[2,1]`, and `[3,2,1]`. Hence, we return `3`. **Constraints:** `1 <= nums.length <= 50` `1 <= nums[i] <= 50`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [1,4,3,3,2]",
12
+ "output": "2 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [3,3,3,3]",
17
+ "output": "1 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [3,2,1]",
22
+ "output": "3 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ 17,
29
+ 11,
30
+ 42,
31
+ 20,
32
+ 14,
33
+ 23,
34
+ 15,
35
+ 4,
36
+ 3,
37
+ 27,
38
+ 18,
39
+ 12,
40
+ 47,
41
+ 36,
42
+ 39,
43
+ 36,
44
+ 7,
45
+ 4,
46
+ 18,
47
+ 15,
48
+ 32,
49
+ 7,
50
+ 7,
51
+ 19,
52
+ 5,
53
+ 31,
54
+ 16,
55
+ 37,
56
+ 15,
57
+ 19,
58
+ 26,
59
+ 17,
60
+ 19,
61
+ 42,
62
+ 47,
63
+ 47,
64
+ 33
65
+ ],
66
+ "output": 4
67
+ },
68
+ {
69
+ "input": [
70
+ 4,
71
+ 41,
72
+ 47,
73
+ 46,
74
+ 12,
75
+ 46,
76
+ 22,
77
+ 9,
78
+ 27,
79
+ 11,
80
+ 41,
81
+ 47,
82
+ 7,
83
+ 21,
84
+ 6,
85
+ 35,
86
+ 48,
87
+ 47,
88
+ 39,
89
+ 30,
90
+ 12,
91
+ 50,
92
+ 36,
93
+ 16,
94
+ 36,
95
+ 23,
96
+ 3,
97
+ 34,
98
+ 21,
99
+ 4,
100
+ 48,
101
+ 11,
102
+ 22,
103
+ 13,
104
+ 27,
105
+ 40,
106
+ 47,
107
+ 46,
108
+ 20,
109
+ 3,
110
+ 4,
111
+ 46,
112
+ 13,
113
+ 50,
114
+ 8,
115
+ 6
116
+ ],
117
+ "output": 5
118
+ },
119
+ {
120
+ "input": [
121
+ 10,
122
+ 50,
123
+ 10,
124
+ 10,
125
+ 12,
126
+ 48,
127
+ 21,
128
+ 5,
129
+ 7,
130
+ 23,
131
+ 37,
132
+ 29,
133
+ 15,
134
+ 23,
135
+ 28
136
+ ],
137
+ "output": 4
138
+ },
139
+ {
140
+ "input": [
141
+ 32,
142
+ 6,
143
+ 23,
144
+ 12,
145
+ 49,
146
+ 23,
147
+ 29,
148
+ 33,
149
+ 47,
150
+ 48,
151
+ 7,
152
+ 42,
153
+ 10,
154
+ 13,
155
+ 2,
156
+ 8,
157
+ 11,
158
+ 34,
159
+ 7,
160
+ 3,
161
+ 34,
162
+ 35,
163
+ 10,
164
+ 35,
165
+ 23,
166
+ 29,
167
+ 12,
168
+ 48,
169
+ 41,
170
+ 10,
171
+ 40,
172
+ 30
173
+ ],
174
+ "output": 5
175
+ },
176
+ {
177
+ "input": [
178
+ 17,
179
+ 29,
180
+ 10,
181
+ 39,
182
+ 14,
183
+ 18,
184
+ 12,
185
+ 3,
186
+ 21,
187
+ 49,
188
+ 16,
189
+ 42,
190
+ 7,
191
+ 13,
192
+ 17,
193
+ 38,
194
+ 2,
195
+ 9,
196
+ 42,
197
+ 22,
198
+ 8,
199
+ 47,
200
+ 1,
201
+ 27,
202
+ 41,
203
+ 16,
204
+ 33,
205
+ 23,
206
+ 16,
207
+ 15,
208
+ 21,
209
+ 22,
210
+ 14,
211
+ 38,
212
+ 29,
213
+ 28,
214
+ 30,
215
+ 15
216
+ ],
217
+ "output": 4
218
+ }
219
+ ],
220
+ "haskell_template": "longestMonotonicSubarray :: [Int] -> Int\nlongestMonotonicSubarray nums ",
221
+ "ocaml_template": "let longestMonotonicSubarray (nums: int list) : int = ",
222
+ "scala_template": "def longestMonotonicSubarray(nums: List[Int]): Int = { \n \n}",
223
+ "java_template": "class Solution {\n public int longestMonotonicSubarray(int[] nums) {\n \n }\n}",
224
+ "python_template": "class Solution(object):\n def longestMonotonicSubarray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
225
+ }
longest_strictly_increasing_or_strictly_decreasing_subarray/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let longestMonotonicSubarray (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 2 (longestMonotonicSubarray [1;4;3;3;2])
13
+
14
+ let test2 _ = assert_equal 1 (longestMonotonicSubarray [3;3;3;3])
15
+
16
+ let test3 _ = assert_equal 3 (longestMonotonicSubarray [3;2;1])
17
+
18
+ let test4 _ = assert_equal 3 (longestMonotonicSubarray [17; 11; 42; 20; 14; 23; 15; 4; 3; 27; 18; 12; 47; 36; 39; 36; 7; 4; 18; 15; 32; 7; 7; 19; 5; 31; 16; 37; 15; 19; 26; 17; 19; 42; 47; 47; 33])
19
+
20
+ let test5 _ = assert_equal 3 (longestMonotonicSubarray [4; 41; 47; 46; 12; 46; 22; 9; 27; 11; 41; 47; 7; 21; 6; 35; 48; 47; 39; 30; 12; 50; 36; 16; 36; 23; 3; 34; 21; 4; 48; 11; 22; 13; 27; 40; 47; 46; 20; 3; 4; 46; 13; 50; 8; 6])
21
+
22
+ let test6 _ = assert_equal 3 (longestMonotonicSubarray [10; 50; 10; 10; 12; 48; 21; 5; 7; 23; 37; 29; 15; 23; 28])
23
+
24
+ let test7 _ = assert_equal 3 (longestMonotonicSubarray [32; 6; 23; 12; 49; 23; 29; 33; 47; 48; 7; 42; 10; 13; 2; 8; 11; 34; 7; 3; 34; 35; 10; 35; 23; 29; 12; 48; 41; 10; 40; 30])
25
+
26
+ let test8 _ = assert_equal 3 (longestMonotonicSubarray [17; 29; 10; 39; 14; 18; 12; 3; 21; 49; 16; 42; 7; 13; 17; 38; 2; 9; 42; 22; 8; 47; 1; 27; 41; 16; 33; 23; 16; 15; 21; 22; 14; 38; 29; 28; 30; 15])
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for longestMonotonicSubarray" >::: [
31
+
32
+ "test1" >:: test1;
33
+ "test2" >:: test2;
34
+ "test3" >:: test3;
35
+ "test4" >:: test4;
36
+ "test5" >:: test5;
37
+ "test6" >:: test6;
38
+ "test7" >:: test7;
39
+ "test8" >:: test8;
40
+ ]
41
+
42
+
43
+ (* Running the tests *)
44
+ let () = run_test_tt_main suite
45
+ end