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

6eee26792c406aadb14f1a9f1a5570568fbd757659dfa2a1a89f4f1d3a5318b2

Browse files
Files changed (50) hide show
  1. lexicographically_minimum_string_after_removing_stars/meta.json +47 -0
  2. lexicographically_minimum_string_after_removing_stars/ocaml_tests/main.ml +42 -0
  3. lexicographically_minimum_string_after_removing_stars/scala_tests/MySuite.scala +32 -0
  4. lexicographically_smallest_beautiful_string/.DS_Store +0 -0
  5. lexicographically_smallest_beautiful_string/haskell_tests/Main.hs +24 -0
  6. lexicographically_smallest_beautiful_string/java_tests/Main.java +21 -0
  7. lexicographically_smallest_beautiful_string/meta.json +26 -0
  8. lexicographically_smallest_beautiful_string/ocaml_tests/main.ml +26 -0
  9. lexicographically_smallest_beautiful_string/scala_tests/MySuite.scala +12 -0
  10. lexicographically_smallest_generated_string/java_tests/Main.java +25 -0
  11. lexicographically_smallest_palindrome/haskell_tests/Main.hs +44 -0
  12. lexicographically_smallest_palindrome/java_tests/Main.java +24 -0
  13. lexicographically_smallest_palindrome/meta.json +52 -0
  14. lexicographically_smallest_palindrome/ocaml_tests/main.ml +45 -0
  15. lexicographically_smallest_palindrome/scala_tests/MySuite.scala +36 -0
  16. lexicographically_smallest_string_after_a_swap/haskell_tests/Main.hs +26 -0
  17. lexicographically_smallest_string_after_a_swap/java_tests/Main.java +20 -0
  18. lexicographically_smallest_string_after_a_swap/meta.json +26 -0
  19. lexicographically_smallest_string_after_a_swap/ocaml_tests/main.ml +27 -0
  20. lexicographically_smallest_string_after_a_swap/scala_tests/MySuite.scala +12 -0
  21. lexicographically_smallest_string_after_substring_operation/haskell_tests/Main.hs +0 -0
  22. lexicographically_smallest_string_after_substring_operation/java_tests/Main.java +28 -0
  23. lexicographically_smallest_string_after_substring_operation/meta.json +0 -0
  24. lexicographically_smallest_string_after_substring_operation/ocaml_tests/main.ml +0 -0
  25. lexicographically_smallest_string_after_substring_operation/scala_tests/MySuite.scala +0 -0
  26. longest_alternating_subarray/haskell_tests/Main.hs +41 -0
  27. longest_alternating_subarray/java_tests/Main.java +20 -0
  28. longest_alternating_subarray/meta.json +244 -0
  29. longest_alternating_subarray/ocaml_tests/main.ml +42 -0
  30. longest_alternating_subarray/scala_tests/MySuite.scala +32 -0
  31. longest_binary_subsequence_less_than_or_equal_to_k/haskell_tests/Main.hs +45 -0
  32. longest_binary_subsequence_less_than_or_equal_to_k/java_tests/Main.java +21 -0
  33. longest_binary_subsequence_less_than_or_equal_to_k/meta.json +76 -0
  34. longest_binary_subsequence_less_than_or_equal_to_k/ocaml_tests/main.ml +47 -0
  35. longest_binary_subsequence_less_than_or_equal_to_k/scala_tests/MySuite.scala +40 -0
  36. longest_even_odd_subarray_with_threshold/haskell_tests/Main.hs +45 -0
  37. longest_even_odd_subarray_with_threshold/java_tests/Main.java +25 -0
  38. longest_even_odd_subarray_with_threshold/meta.json +631 -0
  39. longest_even_odd_subarray_with_threshold/ocaml_tests/main.ml +50 -0
  40. longest_even_odd_subarray_with_threshold/scala_tests/MySuite.scala +44 -0
  41. longest_ideal_subsequence/.DS_Store +0 -0
  42. longest_ideal_subsequence/haskell_tests/Main.hs +24 -0
  43. longest_ideal_subsequence/java_tests/Main.java +21 -0
  44. longest_ideal_subsequence/meta.json +0 -0
  45. longest_ideal_subsequence/ocaml_tests/main.ml +26 -0
  46. longest_ideal_subsequence/scala_tests/MySuite.scala +12 -0
  47. longest_increasing_subsequence_ii/.DS_Store +0 -0
  48. longest_increasing_subsequence_ii/haskell_tests/Main.hs +27 -0
  49. longest_increasing_subsequence_ii/java_tests/Main.java +25 -0
  50. longest_increasing_subsequence_ii/meta.json +215 -0
lexicographically_minimum_string_after_removing_stars/meta.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3445,
3
+ "name": "lexicographically_minimum_string_after_removing_stars",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/",
6
+ "date": "2024-05-26 00:00:00",
7
+ "task_description": "You are given a string `s`. It may contain any number of `'*'` characters. Your task is to remove all `'*'` characters. While there is a `'*'`, do the following operation: Delete the leftmost `'*'` and the **smallest** non-`'*'` character to its _left_. If there are several smallest characters, you can delete any of them. Return the lexicographically smallest resulting string after removing all `'*'` characters. **Example 1:** **Input:** s = \"aaba*\" **Output:** \"aab\" **Explanation:** We should delete one of the `'a'` characters with `'*'`. If we choose `s[3]`, `s` becomes the lexicographically smallest. **Example 2:** **Input:** s = \"abc\" **Output:** \"abc\" **Explanation:** There is no `'*'` in the string. **Constraints:** `1 <= s.length <= 105` `s` consists only of lowercase English letters and `'*'`. The input is generated such that it is possible to delete all `'*'` characters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"aaba*\"",
12
+ "output": "\"aab\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"abc\"",
17
+ "output": "\"abc\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": "em*wg*f**ybr*l*pab*qibci**lb*a*iem**fa*hdovwy*azsxhmnldzu**vy*chsph**mrpcspuiykrgeevj*n***c*",
23
+ "output": "wyrpqiilimhovwyzsxhmnlzuvyhspmrpspuiykrvjn"
24
+ },
25
+ {
26
+ "input": "***v**tn**yz*ue*posifv**x*b*p****vskqa*zt*s***uo*nt*iaod**d",
27
+ "output": "zvxvztutiod"
28
+ },
29
+ {
30
+ "input": "*eu*i*crro****pdthvkhfmb*cgrqdimoujhvszay**wjwo",
31
+ "output": "updthvkhfmgrqdimoujhvszywjwo"
32
+ },
33
+ {
34
+ "input": "ydmb*****vxtav*",
35
+ "output": "vxtv"
36
+ },
37
+ {
38
+ "input": "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx",
39
+ "output": "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx"
40
+ }
41
+ ],
42
+ "haskell_template": "clearStars :: String -> String\nclearStars s ",
43
+ "ocaml_template": "let clearStars (s: string) : string = ",
44
+ "scala_template": "def clearStars(s: String): String = { \n \n}",
45
+ "java_template": "class Solution {\n public String clearStars(String s) {\n \n }\n}",
46
+ "python_template": "class Solution(object):\n def clearStars(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
47
+ }
lexicographically_minimum_string_after_removing_stars/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let clearStars (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "aab" (clearStars "aaba*")
13
+
14
+ let test2 _ = assert_equal "abc" (clearStars "abc")
15
+
16
+ let test3 _ = assert_equal "abc" (clearStars "em*wg*f**ybr*l*pab*qibci**lb*a*iem**fa*hdovwy*azsxhmnldzu**vy*chsph**mrpcspuiykrgeevj*n***c*")
17
+
18
+ let test4 _ = assert_equal "abc" (clearStars "***v**tn**yz*ue*posifv**x*b*p****vskqa*zt*s***uo*nt*iaod**d")
19
+
20
+ let test5 _ = assert_equal "abc" (clearStars "*eu*i*crro****pdthvkhfmb*cgrqdimoujhvszay**wjwo")
21
+
22
+ let test6 _ = assert_equal "abc" (clearStars "ydmb*****vxtav*")
23
+
24
+ let test7 _ = assert_equal "abc" (clearStars "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx")
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for clearStars" >::: [
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
lexicographically_minimum_string_after_removing_stars/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.clearStars("aaba*"), "aab")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.clearStars("abc"), "abc")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.clearStars(",e,m,*,w,g,*,f,*,*,y,b,r,*,l,*,p,a,b,*,q,i,b,c,i,*,*,l,b,*,a,*,i,e,m,*,*,f,a,*,h,d,o,v,w,y,*,a,z,s,x,h,m,n,l,d,z,u,*,*,v,y,*,c,h,s,p,h,*,*,m,r,p,c,s,p,u,i,y,k,r,g,e,e,v,j,*,n,*,*,*,c,*,"), "wyrpqiilimhovwyzsxhmnlzuvyhspmrpspuiykrvjn")
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.clearStars(",*,*,*,v,*,*,t,n,*,*,y,z,*,u,e,*,p,o,s,i,f,v,*,*,x,*,b,*,p,*,*,*,*,v,s,k,q,a,*,z,t,*,s,*,*,*,u,o,*,n,t,*,i,a,o,d,*,*,d,"), "zvxvztutiod")
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.clearStars(",*,e,u,*,i,*,c,r,r,o,*,*,*,*,p,d,t,h,v,k,h,f,m,b,*,c,g,r,q,d,i,m,o,u,j,h,v,s,z,a,y,*,*,w,j,w,o,"), "updthvkhfmgrqdimoujhvszywjwo")
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.clearStars(",y,d,m,b,*,*,*,*,*,v,x,t,a,v,*,"), "vxtv")
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.clearStars(",e,h,o,n,l,v,m,y,m,g,h,w,l,l,s,i,f,h,q,t,o,g,j,t,f,q,y,w,h,m,a,a,f,q,e,y,w,u,w,e,a,b,o,z,q,l,x,"), "ehonlvmymghwllsifhqtogjtfqywhmaafqeywuweabozqlx")
30
+ }
31
+
32
+ }
lexicographically_smallest_beautiful_string/.DS_Store ADDED
Binary file (6.15 kB). View file
 
lexicographically_smallest_beautiful_string/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 (smallestBeautifulString \"abcz \" 26)," "abda" (smallestBeautifulString "abcz" 26))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (smallestBeautifulString \"dc \" 4)," "" (smallestBeautifulString "dc" 4))
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
lexicographically_smallest_beautiful_string/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("26", smallestBeautifulString("abcz", 26));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("4", smallestBeautifulString("dc", 4));
19
+ }
20
+
21
+ }
lexicographically_smallest_beautiful_string/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2687,
3
+ "name": "lexicographically_smallest_beautiful_string",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/lexicographically-smallest-beautiful-string/",
6
+ "date": "1682208000000",
7
+ "task_description": "A string is **beautiful** if: It consists of the first `k` letters of the English lowercase alphabet. It does not contain any substring of length `2` or more which is a palindrome. You are given a beautiful string `s` of length `n` and a positive integer `k`. Return _the lexicographically smallest string of length _`n`_, which is larger than _`s`_ and is **beautiful**_. If there is no such string, return an empty string. A string `a` is lexicographically larger than a string `b` (of the same length) if in the first position where `a` and `b` differ, `a` has a character strictly larger than the corresponding character in `b`. For example, `\"abcd\"` is lexicographically larger than `\"abcc\"` because the first position they differ is at the fourth character, and `d` is greater than `c`. **Example 1:** ``` **Input:** s = \"abcz\", k = 26 **Output:** \"abda\" **Explanation:** The string \"abda\" is beautiful and lexicographically larger than the string \"abcz\". It can be proven that there is no string that is lexicographically larger than the string \"abcz\", beautiful, and lexicographically smaller than the string \"abda\". ``` **Example 2:** ``` **Input:** s = \"dc\", k = 4 **Output:** \"\" **Explanation:** It can be proven that there is no string that is lexicographically larger than the string \"dc\" and is beautiful. ``` **Constraints:** `1 <= n == s.length <= 105` `4 <= k <= 26` `s` is a beautiful string.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"abcz\", k = 26",
12
+ "output": "\"abda\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"dc\", k = 4",
17
+ "output": "\"\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "smallestBeautifulString :: String -> Int -> String\nsmallestBeautifulString s k ",
22
+ "ocaml_template": "let smallestBeautifulString (s: string) (k: int) : string = ",
23
+ "scala_template": "def smallestBeautifulString(s: String,k: Int): String = { \n \n}",
24
+ "java_template": "public static String smallestBeautifulString(String s, int k) {\n\n}",
25
+ "python_template": "class Solution(object):\n def smallestBeautifulString(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: str\n \"\"\"\n "
26
+ }
lexicographically_smallest_beautiful_string/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 "abda" (smallestBeautifulString "abcz" 26)
12
+
13
+ let test2 _ = assert_equal "" (smallestBeautifulString "dc" 4)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for smallestBeautifulString" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
lexicographically_smallest_beautiful_string/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.smallestBeautifulString("abcz",26), "abda")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.smallestBeautifulString("dc",4), "")
10
+ }
11
+
12
+ }
lexicographically_smallest_generated_string/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("ab", generateString("TFTF", "ab"));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals("abc", generateString("TFTF", "abc"));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals("d", generateString("F", "d"));
23
+ }
24
+
25
+ }
lexicographically_smallest_palindrome/haskell_tests/Main.hs ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ makeSmallestPalindrome :: String -> String
7
+ makeSmallestPalindrome s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (makeSmallestPalindrome \"egcfe \")," "efcfe" (makeSmallestPalindrome "egcfe"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (makeSmallestPalindrome \"abcd \")," "abba" (makeSmallestPalindrome "abcd"))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (makeSmallestPalindrome \"seven \")," "neven" (makeSmallestPalindrome "seven"))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (makeSmallestPalindrome \"ambdznuydmjfhqcgfpuhtjrrydrqhtralekhdfinhznilnjq \")," "ajbdinuhdifdhkcgapthqjdrrdjqhtpagckhdfidhunidbja" (makeSmallestPalindrome "ambdznuydmjfhqcgfpuhtjrrydrqhtralekhdfinhznilnjq"))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (makeSmallestPalindrome \"yitjlmpdttfsujkjvvjtothhlnalgbugleblbxkndttmtvceeqhcgvzezeaykbcxlnocmuofwxecdbxbndimpctxcxjzwfgayqsdavruxprxsgafgicxcpqxpebxcgsfpiuluxlwcpwquqmijingphfwmusgndcelsmgrkaiwfgblllhhqqbksermmpgvklqyheovdnvckrwzmjqipnwxfaasphyazriaokkylhmsmgghkceakwsinnksicbcvqaufudshhsqefiggrvedykjpmjnebyriqnppzeilctkctnrhrudctlclcgfibkfesqcjffbsyfaxsrztsuihjsasrbwfihsfytracpquzamgrwoakqeoxbskilnrpqcnefiykskszofphrphswivglaxafypbfyyghqvitarztimoculhmqmcqfovwssekqeszllcbjwtisgmnqygybpihahhzpqihwazlysuuzlsspgpyjlfplvehlspmlyagivxvyejcxcjdztacetggpgqtdbmguethgkllhegaoqklewkwbmnfwbjtgelbdzfjoctvguvnlagoksbmpdvhrxjysxobfmifpskndpwsozhlsmcfmygtbczxxmzginnhbxgwvibcufdufuvfxrkmahxqaqxsyf \")," "fisjlapdhafkrjfjufjdftcbinaggbhgleblbxkncbtgtmcceqhcgosepdakkbcilfbcmsofwrecdbmbndigacnvcgjtcfgaydbdagrjbpfnmbafgeckcoageeblcghfeiglbdlqcpggtecajidgchcjeusgndcallmgrkaevfgbljlhgpqbksermmlgakhiqhehhahicbrgymjmgpitwfaallhsaqkeaokkofhcmmgghkceaitsianisicbcvfapffasahgqefiggrhedokjkmjnebencqnpnleilbtkcqkahrrdcalclccaibkfehicjbfbasfaisrttrsiafsabfbjcihefkbiacclclacdrrhakqcktblielnpnqcnebenjmkjkodehrggifeqghasaffpafvcbcisinaistiaeckhggmmchfokkoaekqashllaafwtipgmjmygrbcihahhehqihkaglmmreskbqpghljlbgfveakrgmllacdngsuejchcgdijacetggpcqldblgiefhgclbeegaockcegfabmnfpbjrgadbdyagfctjgcvncagidnbmbdcerwfosmcbflicbkkadpesogchqeccmtgtbcnkxblbelghbgganibctfdjfujfjrkfahdpaljsif" (makeSmallestPalindrome "yitjlmpdttfsujkjvvjtothhlnalgbugleblbxkndttmtvceeqhcgvzezeaykbcxlnocmuofwxecdbxbndimpctxcxjzwfgayqsdavruxprxsgafgicxcpqxpebxcgsfpiuluxlwcpwquqmijingphfwmusgndcelsmgrkaiwfgblllhhqqbksermmpgvklqyheovdnvckrwzmjqipnwxfaasphyazriaokkylhmsmgghkceakwsinnksicbcvqaufudshhsqefiggrvedykjpmjnebyriqnppzeilctkctnrhrudctlclcgfibkfesqcjffbsyfaxsrztsuihjsasrbwfihsfytracpquzamgrwoakqeoxbskilnrpqcnefiykskszofphrphswivglaxafypbfyyghqvitarztimoculhmqmcqfovwssekqeszllcbjwtisgmnqygybpihahhzpqihwazlysuuzlsspgpyjlfplvehlspmlyagivxvyejcxcjdztacetggpgqtdbmguethgkllhegaoqklewkwbmnfwbjtgelbdzfjoctvguvnlagoksbmpdvhrxjysxobfmifpskndpwsozhlsmcfmygtbczxxmzginnhbxgwvibcufdufuvfxrkmahxqaqxsyf"))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (makeSmallestPalindrome \"wsmyzvvwfwvynwkbgyrmhhxlbzlotyhxgftzqixzfehhpyctifudibmykwxhjmfajpazzntgtahkyjjwzxismfvthzsoxtenuixmtqgmvtmilfkgaqbnapyiwikbtnloizxazaamlofjhuycsxzzmgzjgwhjltoobhdrrkjujtlxkgzuibrfvgjmdgcknxvnukcfyebzwvdamqaqzrpdxlrhuwxtbqnhvulihbmhyqkcadzystcyqywgmzpbatibagphaejovoiwahmfrdwzqqckcuhfcvwffpvsiyhyuiyzmxhtqrfkhspkyzgmxinpeutpuxbvpvfuirjinikrryeobkuadlack \")," "kcaldaukboeynrkbgijmhhflbvbotphuefniqigzfehhhkcrifhdibmikwhhimfaffavcfhgcackqjjdrfihafiohojeahegabimabgmmgmilfcgaqbdackiwhkbhiloihnabaamlhfjhdpcsqaqmadjgwbelfckbhdrnkcgdmjgkfrbibrfkgjmdgcknrdhbkcflebwgjdamqaqscpdhjfhlmaabanhiolihbkhwikcadbqagcflimgmmgbamibagehaejohoifahifrdjjqkcacghfcvaffafmihhwkimbidhfirckhhhefzgiqinfeuhptobvblfhhmjigbkrnyeobkuadlack" (makeSmallestPalindrome "wsmyzvvwfwvynwkbgyrmhhxlbzlotyhxgftzqixzfehhpyctifudibmykwxhjmfajpazzntgtahkyjjwzxismfvthzsoxtenuixmtqgmvtmilfkgaqbnapyiwikbtnloizxazaamlofjhuycsxzzmgzjgwhjltoobhdrrkjujtlxkgzuibrfvgjmdgcknxvnukcfyebzwvdamqaqzrpdxlrhuwxtbqnhvulihbmhyqkcadzystcyqywgmzpbatibagphaejovoiwahmfrdwzqqckcuhfcvwffpvsiyhyuiyzmxhtqrfkhspkyzgmxinpeutpuxbvpvfuirjinikrryeobkuadlack"))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (makeSmallestPalindrome \"ihyrpkzaorwjlfrkxdbvmicylwwmsbdboqgfkcphplzgpwynvbbpsdnntvtrwzcmdxfmokmvrzucnftjcjmifvzlwudczyedjhohdmiftarkxtsmjxngnmjvyuqveraemtxempakaziyeewrguxxjslqdimsuoxabultcnsabsminivncjrmzvsagujvpmnnuvtoipwmecqfkfwpqddlterisakointsxcjubxkveoeczwtyewraeujavtbvvmekktmqavojsvylncgtwcugozsbthskkpkotszgsfzlvzmkvkfnjfqttftzqqguofjfensrzcgcztnnapszujakvefhyndlghzetvqaesstuvpfbdboygpkeawotbpyjsjihcjbzkbeswxsoilrmgrbptcsumttsgbwihfyzzeajvgfasmnejvjakjdclorldemyybmgjqxexzmuvrihliymhcjrhalmglcuhrmvtszwrvswdysyozhhvnriolieiuwxjavenkxbojtjoltehsydtxm \")," "ihtdpkhaolojlfobxdbemacxluieibdbongfhcohpldgpvrnvbbpmdhnclgmlacmdcfmoilhirucmftecjjgfbylmedcroecdhkadmienarafgsjaengnfhiwbgseraemctebpakalioeewrebkxbjchdimjuobabuaecngabbdbfivncjreaqsaeuhgldnnhfeoiajmecpakftpcdclrenefafoigqqxcftbqfjefeckmtvewfaeujaokbkkmekbsmoaucjsgcllcgsjcuaomsbkemkkbkoajueafwevtmkcefejfqbtfcxqqgiofafenerlcdcptfkapcemjaioefhnndlghueasqaerjcnvifbdbbagnceaubaboujmidhcjbxkberweeoilakapbetcmearesgbwihfngneajsgfaraneimdakhdceorcdemlybfgjjcetfmcurihliomfcdmcalmglcnhdmpbbvnrvpgdlphochfgnobdbieiulxcamebdxbofljoloahkpdthi" (makeSmallestPalindrome "ihyrpkzaorwjlfrkxdbvmicylwwmsbdboqgfkcphplzgpwynvbbpsdnntvtrwzcmdxfmokmvrzucnftjcjmifvzlwudczyedjhohdmiftarkxtsmjxngnmjvyuqveraemtxempakaziyeewrguxxjslqdimsuoxabultcnsabsminivncjrmzvsagujvpmnnuvtoipwmecqfkfwpqddlterisakointsxcjubxkveoeczwtyewraeujavtbvvmekktmqavojsvylncgtwcugozsbthskkpkotszgsfzlvzmkvkfnjfqttftzqqguofjfensrzcgcztnnapszujakvefhyndlghzetvqaesstuvpfbdboygpkeawotbpyjsjihcjbzkbeswxsoilrmgrbptcsumttsgbwihfyzzeajvgfasmnejvjakjdclorldemyybmgjqxexzmuvrihliymhcjrhalmglcuhrmvtszwrvswdysyozhhvnriolieiuwxjavenkxbojtjoltehsydtxm"))
33
+
34
+ test8 :: Test
35
+ test8 = TestCase (assertEqual "for (makeSmallestPalindrome \"yekczcvprfcuoqmsrpvbaepgbtmbrdlcoypkebbzshkkvuaqkdrnjsurhqixaorprkmkdutmjjkeqihqgfpomvjneqkpsgzkwpoxdiedczejnphlecdhrlmvcwakybxzhohqhddhgtgjikbaxfaxktzyihfsjtikaycptfgeucjnengavxdlrstaowjtficdumjgczwdfkjtxieqnzzybapowztnrwiqalxtwqkzxgeopwgdijoebtcypnlzzjttiyyfeuygflifwgoudefganizhvtspstzzjpsazdiobypyadsihttpuuiqyspslmnsblzogcchilqrbmgwovomynkihergmmiayisokxdueuiczyaracnhqhnpxztqcydajjzihrldndgsgvriijbmpuqiqskexcannnhdinstounyfgydoedebipauegnlpekasgjjigavmuutagnuzitoqoxbvcacyuonvxfsrboikzpujjctgbjmbpwjeksnyzwkutnzdmybhlpqlezssjpmvzlkpkkprixoicolikdagrkunrkdlphpukqqjcjlxrvcxamowdqocfjkaqmthcqufkkguyfutwxyfpwkfrpsftbgqbsxynhsyduxesjybykecmbdjmygmrrtpinofjhstyqwpoxntocrrvrczzbwbjaoocgzzajasnyvkhguiuvmnknugtyiwfrplcmjxhfauumjbfdhnnxyyeiqbuizhzdeuybsuqmcfmerjiexceccmddafwojvhirvqtrsfowtigscsuthbebcwgvuaeikhdlfppkqmnhsuunxjlpagbqfhidhpslxqmnbwbgdiwyptnzdijqmklievnhvmzoxbxeilcwpxwnkmcakqxgbvdyvtlbsobwuodrvzz \")," "yekcdcupbfcblqmsdpbbaekabmkbrdlcclieebboshkhnuaikdmnjidrhqixaidgbkbkdqtljjhdihfqbfaoljjneqkhngqkppfldhedcaejgpcbebdhrlcsciakobsrhohqhddhgtfaddbaceaxeijrehfcjqikaycedfgeicbneegavndhdfbamujafhcdmcjgcfwdfkgtniemnuiubakownsajaiqacooajbwbgecpvgdcjoebocwpnlshjfoiipfermgflidbgcedebganexhdtshntxsbpgatdiobfkwadsihttfuugkkfpqchnmbakjfcchdlomamcvovljcjkihepgmldariskkgadeiicciaracnhkhklxvmpcsdaejqihhbdmdgngukiijbmkejipbkebcacjjhdikiobrnffgndoecabibaoegnipekaagjjigagijjgaakepingeoabibaceodngffnrboikidhjjcacbekbpijekmbjiikugngdmdbhhiqjeadscpmvxlkhkhncaraicciiedagkksiradlmgpehikjcjlvovcmamoldhccfjkabmnhcqpfkkguuftthisdawkfboidtagpbsxtnhstdhxenagbedecgbdilfgmrefpiiofjhslnpwcobeojcdgvpcegbwbjaoocaqiajasnwokabuiunmeintgkfdwfcgjcmdchfajumabfdhdnvageenbciegfdecyakiqjcfherjiexaecabddaftghddhqhohrsbokaicsclrhdbebcpgjeacdehdlfppkqgnhkqenjjloafbqfhidhjjltqdkbkbgdiaxiqhrdijnmdkiaunhkhsobbeeilccldrbkmbakeabbpdsmqlbcfbpucdckey" (makeSmallestPalindrome "yekczcvprfcuoqmsrpvbaepgbtmbrdlcoypkebbzshkkvuaqkdrnjsurhqixaorprkmkdutmjjkeqihqgfpomvjneqkpsgzkwpoxdiedczejnphlecdhrlmvcwakybxzhohqhddhgtgjikbaxfaxktzyihfsjtikaycptfgeucjnengavxdlrstaowjtficdumjgczwdfkjtxieqnzzybapowztnrwiqalxtwqkzxgeopwgdijoebtcypnlzzjttiyyfeuygflifwgoudefganizhvtspstzzjpsazdiobypyadsihttpuuiqyspslmnsblzogcchilqrbmgwovomynkihergmmiayisokxdueuiczyaracnhqhnpxztqcydajjzihrldndgsgvriijbmpuqiqskexcannnhdinstounyfgydoedebipauegnlpekasgjjigavmuutagnuzitoqoxbvcacyuonvxfsrboikzpujjctgbjmbpwjeksnyzwkutnzdmybhlpqlezssjpmvzlkpkkprixoicolikdagrkunrkdlphpukqqjcjlxrvcxamowdqocfjkaqmthcqufkkguyfutwxyfpwkfrpsftbgqbsxynhsyduxesjybykecmbdjmygmrrtpinofjhstyqwpoxntocrrvrczzbwbjaoocgzzajasnyvkhguiuvmnknugtyiwfrplcmjxhfauumjbfdhnnxyyeiqbuizhzdeuybsuqmcfmerjiexceccmddafwojvhirvqtrsfowtigscsuthbebcwgvuaeikhdlfppkqmnhsuunxjlpagbqfhidhpslxqmnbwbgdiwyptnzdijqmklievnhvmzoxbxeilcwpxwnkmcakqxgbvdyvtlbsobwuodrvzz"))
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
lexicographically_smallest_palindrome/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("egcfe", makeSmallestPalindrome("egcfe"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("abcd", makeSmallestPalindrome("abcd"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals("seven", makeSmallestPalindrome("seven"));
22
+ }
23
+
24
+ }
lexicographically_smallest_palindrome/meta.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2816,
3
+ "name": "lexicographically_smallest_palindrome",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/lexicographically-smallest-palindrome/",
6
+ "date": "2023-05-14 00:00:00",
7
+ "task_description": "You are given a string `s` consisting of **lowercase English letters**, and you are allowed to perform operations on it. In one operation, you can **replace** a character in `s` with another lowercase English letter. Your task is to make `s` a **palindrome** with the **minimum** **number** **of operations** possible. If there are **multiple palindromes** that can be made using the **minimum** number of operations, make the **lexicographically smallest** one. A string `a` is lexicographically smaller than a string `b` (of the same length) if in the first position where `a` and `b` differ, string `a` has a letter that appears earlier in the alphabet than the corresponding letter in `b`. Return _the resulting palindrome string._ **Example 1:** ``` **Input:** s = \"egcfe\" **Output:** \"efcfe\" **Explanation:** The minimum number of operations to make \"egcfe\" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is \"efcfe\", by changing 'g'. ``` **Example 2:** ``` **Input:** s = \"abcd\" **Output:** \"abba\" **Explanation:** The minimum number of operations to make \"abcd\" a palindrome is 2, and the lexicographically smallest palindrome string we can get by modifying two characters is \"abba\". ``` **Example 3:** ``` **Input:** s = \"seven\" **Output:** \"neven\" **Explanation:** The minimum number of operations to make \"seven\" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is \"neven\". ``` **Constraints:** `1 <= s.length <= 1000` `s` consists of only lowercase English letters.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"egcfe\"",
12
+ "output": "\"efcfe\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"abcd\"",
17
+ "output": "\"abba\" "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "s = \"seven\"",
22
+ "output": "\"neven\" "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": "ambdznuydmjfhqcgfpuhtjrrydrqhtralekhdfinhznilnjq",
28
+ "output": "ajbdinuhdifdhkcgapthqjdrrdjqhtpagckhdfidhunidbja"
29
+ },
30
+ {
31
+ "input": "yitjlmpdttfsujkjvvjtothhlnalgbugleblbxkndttmtvceeqhcgvzezeaykbcxlnocmuofwxecdbxbndimpctxcxjzwfgayqsdavruxprxsgafgicxcpqxpebxcgsfpiuluxlwcpwquqmijingphfwmusgndcelsmgrkaiwfgblllhhqqbksermmpgvklqyheovdnvckrwzmjqipnwxfaasphyazriaokkylhmsmgghkceakwsinnksicbcvqaufudshhsqefiggrvedykjpmjnebyriqnppzeilctkctnrhrudctlclcgfibkfesqcjffbsyfaxsrztsuihjsasrbwfihsfytracpquzamgrwoakqeoxbskilnrpqcnefiykskszofphrphswivglaxafypbfyyghqvitarztimoculhmqmcqfovwssekqeszllcbjwtisgmnqygybpihahhzpqihwazlysuuzlsspgpyjlfplvehlspmlyagivxvyejcxcjdztacetggpgqtdbmguethgkllhegaoqklewkwbmnfwbjtgelbdzfjoctvguvnlagoksbmpdvhrxjysxobfmifpskndpwsozhlsmcfmygtbczxxmzginnhbxgwvibcufdufuvfxrkmahxqaqxsyf",
32
+ "output": "fisjlapdhafkrjfjufjdftcbinaggbhgleblbxkncbtgtmcceqhcgosepdakkbcilfbcmsofwrecdbmbndigacnvcgjtcfgaydbdagrjbpfnmbafgeckcoageeblcghfeiglbdlqcpggtecajidgchcjeusgndcallmgrkaevfgbljlhgpqbksermmlgakhiqhehhahicbrgymjmgpitwfaallhsaqkeaokkofhcmmgghkceaitsianisicbcvfapffasahgqefiggrhedokjkmjnebencqnpnleilbtkcqkahrrdcalclccaibkfehicjbfbasfaisrttrsiafsabfbjcihefkbiacclclacdrrhakqcktblielnpnqcnebenjmkjkodehrggifeqghasaffpafvcbcisinaistiaeckhggmmchfokkoaekqashllaafwtipgmjmygrbcihahhehqihkaglmmreskbqpghljlbgfveakrgmllacdngsuejchcgdijacetggpcqldblgiefhgclbeegaockcegfabmnfpbjrgadbdyagfctjgcvncagidnbmbdcerwfosmcbflicbkkadpesogchqeccmtgtbcnkxblbelghbgganibctfdjfujfjrkfahdpaljsif"
33
+ },
34
+ {
35
+ "input": "wsmyzvvwfwvynwkbgyrmhhxlbzlotyhxgftzqixzfehhpyctifudibmykwxhjmfajpazzntgtahkyjjwzxismfvthzsoxtenuixmtqgmvtmilfkgaqbnapyiwikbtnloizxazaamlofjhuycsxzzmgzjgwhjltoobhdrrkjujtlxkgzuibrfvgjmdgcknxvnukcfyebzwvdamqaqzrpdxlrhuwxtbqnhvulihbmhyqkcadzystcyqywgmzpbatibagphaejovoiwahmfrdwzqqckcuhfcvwffpvsiyhyuiyzmxhtqrfkhspkyzgmxinpeutpuxbvpvfuirjinikrryeobkuadlack",
36
+ "output": "kcaldaukboeynrkbgijmhhflbvbotphuefniqigzfehhhkcrifhdibmikwhhimfaffavcfhgcackqjjdrfihafiohojeahegabimabgmmgmilfcgaqbdackiwhkbhiloihnabaamlhfjhdpcsqaqmadjgwbelfckbhdrnkcgdmjgkfrbibrfkgjmdgcknrdhbkcflebwgjdamqaqscpdhjfhlmaabanhiolihbkhwikcadbqagcflimgmmgbamibagehaejohoifahifrdjjqkcacghfcvaffafmihhwkimbidhfirckhhhefzgiqinfeuhptobvblfhhmjigbkrnyeobkuadlack"
37
+ },
38
+ {
39
+ "input": "ihyrpkzaorwjlfrkxdbvmicylwwmsbdboqgfkcphplzgpwynvbbpsdnntvtrwzcmdxfmokmvrzucnftjcjmifvzlwudczyedjhohdmiftarkxtsmjxngnmjvyuqveraemtxempakaziyeewrguxxjslqdimsuoxabultcnsabsminivncjrmzvsagujvpmnnuvtoipwmecqfkfwpqddlterisakointsxcjubxkveoeczwtyewraeujavtbvvmekktmqavojsvylncgtwcugozsbthskkpkotszgsfzlvzmkvkfnjfqttftzqqguofjfensrzcgcztnnapszujakvefhyndlghzetvqaesstuvpfbdboygpkeawotbpyjsjihcjbzkbeswxsoilrmgrbptcsumttsgbwihfyzzeajvgfasmnejvjakjdclorldemyybmgjqxexzmuvrihliymhcjrhalmglcuhrmvtszwrvswdysyozhhvnriolieiuwxjavenkxbojtjoltehsydtxm",
40
+ "output": "ihtdpkhaolojlfobxdbemacxluieibdbongfhcohpldgpvrnvbbpmdhnclgmlacmdcfmoilhirucmftecjjgfbylmedcroecdhkadmienarafgsjaengnfhiwbgseraemctebpakalioeewrebkxbjchdimjuobabuaecngabbdbfivncjreaqsaeuhgldnnhfeoiajmecpakftpcdclrenefafoigqqxcftbqfjefeckmtvewfaeujaokbkkmekbsmoaucjsgcllcgsjcuaomsbkemkkbkoajueafwevtmkcefejfqbtfcxqqgiofafenerlcdcptfkapcemjaioefhnndlghueasqaerjcnvifbdbbagnceaubaboujmidhcjbxkberweeoilakapbetcmearesgbwihfngneajsgfaraneimdakhdceorcdemlybfgjjcetfmcurihliomfcdmcalmglcnhdmpbbvnrvpgdlphochfgnobdbieiulxcamebdxbofljoloahkpdthi"
41
+ },
42
+ {
43
+ "input": "yekczcvprfcuoqmsrpvbaepgbtmbrdlcoypkebbzshkkvuaqkdrnjsurhqixaorprkmkdutmjjkeqihqgfpomvjneqkpsgzkwpoxdiedczejnphlecdhrlmvcwakybxzhohqhddhgtgjikbaxfaxktzyihfsjtikaycptfgeucjnengavxdlrstaowjtficdumjgczwdfkjtxieqnzzybapowztnrwiqalxtwqkzxgeopwgdijoebtcypnlzzjttiyyfeuygflifwgoudefganizhvtspstzzjpsazdiobypyadsihttpuuiqyspslmnsblzogcchilqrbmgwovomynkihergmmiayisokxdueuiczyaracnhqhnpxztqcydajjzihrldndgsgvriijbmpuqiqskexcannnhdinstounyfgydoedebipauegnlpekasgjjigavmuutagnuzitoqoxbvcacyuonvxfsrboikzpujjctgbjmbpwjeksnyzwkutnzdmybhlpqlezssjpmvzlkpkkprixoicolikdagrkunrkdlphpukqqjcjlxrvcxamowdqocfjkaqmthcqufkkguyfutwxyfpwkfrpsftbgqbsxynhsyduxesjybykecmbdjmygmrrtpinofjhstyqwpoxntocrrvrczzbwbjaoocgzzajasnyvkhguiuvmnknugtyiwfrplcmjxhfauumjbfdhnnxyyeiqbuizhzdeuybsuqmcfmerjiexceccmddafwojvhirvqtrsfowtigscsuthbebcwgvuaeikhdlfppkqmnhsuunxjlpagbqfhidhpslxqmnbwbgdiwyptnzdijqmklievnhvmzoxbxeilcwpxwnkmcakqxgbvdyvtlbsobwuodrvzz",
44
+ "output": "yekcdcupbfcblqmsdpbbaekabmkbrdlcclieebboshkhnuaikdmnjidrhqixaidgbkbkdqtljjhdihfqbfaoljjneqkhngqkppfldhedcaejgpcbebdhrlcsciakobsrhohqhddhgtfaddbaceaxeijrehfcjqikaycedfgeicbneegavndhdfbamujafhcdmcjgcfwdfkgtniemnuiubakownsajaiqacooajbwbgecpvgdcjoebocwpnlshjfoiipfermgflidbgcedebganexhdtshntxsbpgatdiobfkwadsihttfuugkkfpqchnmbakjfcchdlomamcvovljcjkihepgmldariskkgadeiicciaracnhkhklxvmpcsdaejqihhbdmdgngukiijbmkejipbkebcacjjhdikiobrnffgndoecabibaoegnipekaagjjigagijjgaakepingeoabibaceodngffnrboikidhjjcacbekbpijekmbjiikugngdmdbhhiqjeadscpmvxlkhkhncaraicciiedagkksiradlmgpehikjcjlvovcmamoldhccfjkabmnhcqpfkkguuftthisdawkfboidtagpbsxtnhstdhxenagbedecgbdilfgmrefpiiofjhslnpwcobeojcdgvpcegbwbjaoocaqiajasnwokabuiunmeintgkfdwfcgjcmdchfajumabfdhdnvageenbciegfdecyakiqjcfherjiexaecabddaftghddhqhohrsbokaicsclrhdbebcpgjeacdehdlfppkqgnhkqenjjloafbqfhidhjjltqdkbkbgdiaxiqhrdijnmdkiaunhkhsobbeeilccldrbkmbakeabbpdsmqlbcfbpucdckey"
45
+ }
46
+ ],
47
+ "haskell_template": "makeSmallestPalindrome :: String -> String\nmakeSmallestPalindrome s ",
48
+ "ocaml_template": "let makeSmallestPalindrome (s: string) : string = ",
49
+ "scala_template": "def makeSmallestPalindrome(s: String): String = { \n \n}",
50
+ "java_template": "class Solution {\n public String makeSmallestPalindrome(String s) {\n \n }\n}",
51
+ "python_template": "class Solution(object):\n def makeSmallestPalindrome(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
52
+ }
lexicographically_smallest_palindrome/ocaml_tests/main.ml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let makeSmallestPalindrome (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "efcfe" (makeSmallestPalindrome "egcfe")
13
+
14
+ let test2 _ = assert_equal "abba" (makeSmallestPalindrome "abcd")
15
+
16
+ let test3 _ = assert_equal "neven" (makeSmallestPalindrome "seven")
17
+
18
+ let test4 _ = assert_equal "neven" (makeSmallestPalindrome "ambdznuydmjfhqcgfpuhtjrrydrqhtralekhdfinhznilnjq")
19
+
20
+ let test5 _ = assert_equal "neven" (makeSmallestPalindrome "yitjlmpdttfsujkjvvjtothhlnalgbugleblbxkndttmtvceeqhcgvzezeaykbcxlnocmuofwxecdbxbndimpctxcxjzwfgayqsdavruxprxsgafgicxcpqxpebxcgsfpiuluxlwcpwquqmijingphfwmusgndcelsmgrkaiwfgblllhhqqbksermmpgvklqyheovdnvckrwzmjqipnwxfaasphyazriaokkylhmsmgghkceakwsinnksicbcvqaufudshhsqefiggrvedykjpmjnebyriqnppzeilctkctnrhrudctlclcgfibkfesqcjffbsyfaxsrztsuihjsasrbwfihsfytracpquzamgrwoakqeoxbskilnrpqcnefiykskszofphrphswivglaxafypbfyyghqvitarztimoculhmqmcqfovwssekqeszllcbjwtisgmnqygybpihahhzpqihwazlysuuzlsspgpyjlfplvehlspmlyagivxvyejcxcjdztacetggpgqtdbmguethgkllhegaoqklewkwbmnfwbjtgelbdzfjoctvguvnlagoksbmpdvhrxjysxobfmifpskndpwsozhlsmcfmygtbczxxmzginnhbxgwvibcufdufuvfxrkmahxqaqxsyf")
21
+
22
+ let test6 _ = assert_equal "neven" (makeSmallestPalindrome "wsmyzvvwfwvynwkbgyrmhhxlbzlotyhxgftzqixzfehhpyctifudibmykwxhjmfajpazzntgtahkyjjwzxismfvthzsoxtenuixmtqgmvtmilfkgaqbnapyiwikbtnloizxazaamlofjhuycsxzzmgzjgwhjltoobhdrrkjujtlxkgzuibrfvgjmdgcknxvnukcfyebzwvdamqaqzrpdxlrhuwxtbqnhvulihbmhyqkcadzystcyqywgmzpbatibagphaejovoiwahmfrdwzqqckcuhfcvwffpvsiyhyuiyzmxhtqrfkhspkyzgmxinpeutpuxbvpvfuirjinikrryeobkuadlack")
23
+
24
+ let test7 _ = assert_equal "neven" (makeSmallestPalindrome "ihyrpkzaorwjlfrkxdbvmicylwwmsbdboqgfkcphplzgpwynvbbpsdnntvtrwzcmdxfmokmvrzucnftjcjmifvzlwudczyedjhohdmiftarkxtsmjxngnmjvyuqveraemtxempakaziyeewrguxxjslqdimsuoxabultcnsabsminivncjrmzvsagujvpmnnuvtoipwmecqfkfwpqddlterisakointsxcjubxkveoeczwtyewraeujavtbvvmekktmqavojsvylncgtwcugozsbthskkpkotszgsfzlvzmkvkfnjfqttftzqqguofjfensrzcgcztnnapszujakvefhyndlghzetvqaesstuvpfbdboygpkeawotbpyjsjihcjbzkbeswxsoilrmgrbptcsumttsgbwihfyzzeajvgfasmnejvjakjdclorldemyybmgjqxexzmuvrihliymhcjrhalmglcuhrmvtszwrvswdysyozhhvnriolieiuwxjavenkxbojtjoltehsydtxm")
25
+
26
+ let test8 _ = assert_equal "neven" (makeSmallestPalindrome "yekczcvprfcuoqmsrpvbaepgbtmbrdlcoypkebbzshkkvuaqkdrnjsurhqixaorprkmkdutmjjkeqihqgfpomvjneqkpsgzkwpoxdiedczejnphlecdhrlmvcwakybxzhohqhddhgtgjikbaxfaxktzyihfsjtikaycptfgeucjnengavxdlrstaowjtficdumjgczwdfkjtxieqnzzybapowztnrwiqalxtwqkzxgeopwgdijoebtcypnlzzjttiyyfeuygflifwgoudefganizhvtspstzzjpsazdiobypyadsihttpuuiqyspslmnsblzogcchilqrbmgwovomynkihergmmiayisokxdueuiczyaracnhqhnpxztqcydajjzihrldndgsgvriijbmpuqiqskexcannnhdinstounyfgydoedebipauegnlpekasgjjigavmuutagnuzitoqoxbvcacyuonvxfsrboikzpujjctgbjmbpwjeksnyzwkutnzdmybhlpqlezssjpmvzlkpkkprixoicolikdagrkunrkdlphpukqqjcjlxrvcxamowdqocfjkaqmthcqufkkguyfutwxyfpwkfrpsftbgqbsxynhsyduxesjybykecmbdjmygmrrtpinofjhstyqwpoxntocrrvrczzbwbjaoocgzzajasnyvkhguiuvmnknugtyiwfrplcmjxhfauumjbfdhnnxyyeiqbuizhzdeuybsuqmcfmerjiexceccmddafwojvhirvqtrsfowtigscsuthbebcwgvuaeikhdlfppkqmnhsuunxjlpagbqfhidhpslxqmnbwbgdiwyptnzdijqmklievnhvmzoxbxeilcwpxwnkmcakqxgbvdyvtlbsobwuodrvzz")
27
+
28
+
29
+ (* Grouping test cases *)
30
+ let suite = "Test Suite for makeSmallestPalindrome" >::: [
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
lexicographically_smallest_palindrome/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.makeSmallestPalindrome("egcfe"), "efcfe")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.makeSmallestPalindrome("abcd"), "abba")
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.makeSmallestPalindrome("seven"), "neven")
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.makeSmallestPalindrome(",a,m,b,d,z,n,u,y,d,m,j,f,h,q,c,g,f,p,u,h,t,j,r,r,y,d,r,q,h,t,r,a,l,e,k,h,d,f,i,n,h,z,n,i,l,n,j,q,"), "ajbdinuhdifdhkcgapthqjdrrdjqhtpagckhdfidhunidbja")
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.makeSmallestPalindrome(",y,i,t,j,l,m,p,d,t,t,f,s,u,j,k,j,v,v,j,t,o,t,h,h,l,n,a,l,g,b,u,g,l,e,b,l,b,x,k,n,d,t,t,m,t,v,c,e,e,q,h,c,g,v,z,e,z,e,a,y,k,b,c,x,l,n,o,c,m,u,o,f,w,x,e,c,d,b,x,b,n,d,i,m,p,c,t,x,c,x,j,z,w,f,g,a,y,q,s,d,a,v,r,u,x,p,r,x,s,g,a,f,g,i,c,x,c,p,q,x,p,e,b,x,c,g,s,f,p,i,u,l,u,x,l,w,c,p,w,q,u,q,m,i,j,i,n,g,p,h,f,w,m,u,s,g,n,d,c,e,l,s,m,g,r,k,a,i,w,f,g,b,l,l,l,h,h,q,q,b,k,s,e,r,m,m,p,g,v,k,l,q,y,h,e,o,v,d,n,v,c,k,r,w,z,m,j,q,i,p,n,w,x,f,a,a,s,p,h,y,a,z,r,i,a,o,k,k,y,l,h,m,s,m,g,g,h,k,c,e,a,k,w,s,i,n,n,k,s,i,c,b,c,v,q,a,u,f,u,d,s,h,h,s,q,e,f,i,g,g,r,v,e,d,y,k,j,p,m,j,n,e,b,y,r,i,q,n,p,p,z,e,i,l,c,t,k,c,t,n,r,h,r,u,d,c,t,l,c,l,c,g,f,i,b,k,f,e,s,q,c,j,f,f,b,s,y,f,a,x,s,r,z,t,s,u,i,h,j,s,a,s,r,b,w,f,i,h,s,f,y,t,r,a,c,p,q,u,z,a,m,g,r,w,o,a,k,q,e,o,x,b,s,k,i,l,n,r,p,q,c,n,e,f,i,y,k,s,k,s,z,o,f,p,h,r,p,h,s,w,i,v,g,l,a,x,a,f,y,p,b,f,y,y,g,h,q,v,i,t,a,r,z,t,i,m,o,c,u,l,h,m,q,m,c,q,f,o,v,w,s,s,e,k,q,e,s,z,l,l,c,b,j,w,t,i,s,g,m,n,q,y,g,y,b,p,i,h,a,h,h,z,p,q,i,h,w,a,z,l,y,s,u,u,z,l,s,s,p,g,p,y,j,l,f,p,l,v,e,h,l,s,p,m,l,y,a,g,i,v,x,v,y,e,j,c,x,c,j,d,z,t,a,c,e,t,g,g,p,g,q,t,d,b,m,g,u,e,t,h,g,k,l,l,h,e,g,a,o,q,k,l,e,w,k,w,b,m,n,f,w,b,j,t,g,e,l,b,d,z,f,j,o,c,t,v,g,u,v,n,l,a,g,o,k,s,b,m,p,d,v,h,r,x,j,y,s,x,o,b,f,m,i,f,p,s,k,n,d,p,w,s,o,z,h,l,s,m,c,f,m,y,g,t,b,c,z,x,x,m,z,g,i,n,n,h,b,x,g,w,v,i,b,c,u,f,d,u,f,u,v,f,x,r,k,m,a,h,x,q,a,q,x,s,y,f,"), "fisjlapdhafkrjfjufjdftcbinaggbhgleblbxkncbtgtmcceqhcgosepdakkbcilfbcmsofwrecdbmbndigacnvcgjtcfgaydbdagrjbpfnmbafgeckcoageeblcghfeiglbdlqcpggtecajidgchcjeusgndcallmgrkaevfgbljlhgpqbksermmlgakhiqhehhahicbrgymjmgpitwfaallhsaqkeaokkofhcmmgghkceaitsianisicbcvfapffasahgqefiggrhedokjkmjnebencqnpnleilbtkcqkahrrdcalclccaibkfehicjbfbasfaisrttrsiafsabfbjcihefkbiacclclacdrrhakqcktblielnpnqcnebenjmkjkodehrggifeqghasaffpafvcbcisinaistiaeckhggmmchfokkoaekqashllaafwtipgmjmygrbcihahhehqihkaglmmreskbqpghljlbgfveakrgmllacdngsuejchcgdijacetggpcqldblgiefhgclbeegaockcegfabmnfpbjrgadbdyagfctjgcvncagidnbmbdcerwfosmcbflicbkkadpesogchqeccmtgtbcnkxblbelghbgganibctfdjfujfjrkfahdpaljsif")
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.makeSmallestPalindrome(",w,s,m,y,z,v,v,w,f,w,v,y,n,w,k,b,g,y,r,m,h,h,x,l,b,z,l,o,t,y,h,x,g,f,t,z,q,i,x,z,f,e,h,h,p,y,c,t,i,f,u,d,i,b,m,y,k,w,x,h,j,m,f,a,j,p,a,z,z,n,t,g,t,a,h,k,y,j,j,w,z,x,i,s,m,f,v,t,h,z,s,o,x,t,e,n,u,i,x,m,t,q,g,m,v,t,m,i,l,f,k,g,a,q,b,n,a,p,y,i,w,i,k,b,t,n,l,o,i,z,x,a,z,a,a,m,l,o,f,j,h,u,y,c,s,x,z,z,m,g,z,j,g,w,h,j,l,t,o,o,b,h,d,r,r,k,j,u,j,t,l,x,k,g,z,u,i,b,r,f,v,g,j,m,d,g,c,k,n,x,v,n,u,k,c,f,y,e,b,z,w,v,d,a,m,q,a,q,z,r,p,d,x,l,r,h,u,w,x,t,b,q,n,h,v,u,l,i,h,b,m,h,y,q,k,c,a,d,z,y,s,t,c,y,q,y,w,g,m,z,p,b,a,t,i,b,a,g,p,h,a,e,j,o,v,o,i,w,a,h,m,f,r,d,w,z,q,q,c,k,c,u,h,f,c,v,w,f,f,p,v,s,i,y,h,y,u,i,y,z,m,x,h,t,q,r,f,k,h,s,p,k,y,z,g,m,x,i,n,p,e,u,t,p,u,x,b,v,p,v,f,u,i,r,j,i,n,i,k,r,r,y,e,o,b,k,u,a,d,l,a,c,k,"), "kcaldaukboeynrkbgijmhhflbvbotphuefniqigzfehhhkcrifhdibmikwhhimfaffavcfhgcackqjjdrfihafiohojeahegabimabgmmgmilfcgaqbdackiwhkbhiloihnabaamlhfjhdpcsqaqmadjgwbelfckbhdrnkcgdmjgkfrbibrfkgjmdgcknrdhbkcflebwgjdamqaqscpdhjfhlmaabanhiolihbkhwikcadbqagcflimgmmgbamibagehaejohoifahifrdjjqkcacghfcvaffafmihhwkimbidhfirckhhhefzgiqinfeuhptobvblfhhmjigbkrnyeobkuadlack")
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.makeSmallestPalindrome(",i,h,y,r,p,k,z,a,o,r,w,j,l,f,r,k,x,d,b,v,m,i,c,y,l,w,w,m,s,b,d,b,o,q,g,f,k,c,p,h,p,l,z,g,p,w,y,n,v,b,b,p,s,d,n,n,t,v,t,r,w,z,c,m,d,x,f,m,o,k,m,v,r,z,u,c,n,f,t,j,c,j,m,i,f,v,z,l,w,u,d,c,z,y,e,d,j,h,o,h,d,m,i,f,t,a,r,k,x,t,s,m,j,x,n,g,n,m,j,v,y,u,q,v,e,r,a,e,m,t,x,e,m,p,a,k,a,z,i,y,e,e,w,r,g,u,x,x,j,s,l,q,d,i,m,s,u,o,x,a,b,u,l,t,c,n,s,a,b,s,m,i,n,i,v,n,c,j,r,m,z,v,s,a,g,u,j,v,p,m,n,n,u,v,t,o,i,p,w,m,e,c,q,f,k,f,w,p,q,d,d,l,t,e,r,i,s,a,k,o,i,n,t,s,x,c,j,u,b,x,k,v,e,o,e,c,z,w,t,y,e,w,r,a,e,u,j,a,v,t,b,v,v,m,e,k,k,t,m,q,a,v,o,j,s,v,y,l,n,c,g,t,w,c,u,g,o,z,s,b,t,h,s,k,k,p,k,o,t,s,z,g,s,f,z,l,v,z,m,k,v,k,f,n,j,f,q,t,t,f,t,z,q,q,g,u,o,f,j,f,e,n,s,r,z,c,g,c,z,t,n,n,a,p,s,z,u,j,a,k,v,e,f,h,y,n,d,l,g,h,z,e,t,v,q,a,e,s,s,t,u,v,p,f,b,d,b,o,y,g,p,k,e,a,w,o,t,b,p,y,j,s,j,i,h,c,j,b,z,k,b,e,s,w,x,s,o,i,l,r,m,g,r,b,p,t,c,s,u,m,t,t,s,g,b,w,i,h,f,y,z,z,e,a,j,v,g,f,a,s,m,n,e,j,v,j,a,k,j,d,c,l,o,r,l,d,e,m,y,y,b,m,g,j,q,x,e,x,z,m,u,v,r,i,h,l,i,y,m,h,c,j,r,h,a,l,m,g,l,c,u,h,r,m,v,t,s,z,w,r,v,s,w,d,y,s,y,o,z,h,h,v,n,r,i,o,l,i,e,i,u,w,x,j,a,v,e,n,k,x,b,o,j,t,j,o,l,t,e,h,s,y,d,t,x,m,"), "ihtdpkhaolojlfobxdbemacxluieibdbongfhcohpldgpvrnvbbpmdhnclgmlacmdcfmoilhirucmftecjjgfbylmedcroecdhkadmienarafgsjaengnfhiwbgseraemctebpakalioeewrebkxbjchdimjuobabuaecngabbdbfivncjreaqsaeuhgldnnhfeoiajmecpakftpcdclrenefafoigqqxcftbqfjefeckmtvewfaeujaokbkkmekbsmoaucjsgcllcgsjcuaomsbkemkkbkoajueafwevtmkcefejfqbtfcxqqgiofafenerlcdcptfkapcemjaioefhnndlghueasqaerjcnvifbdbbagnceaubaboujmidhcjbxkberweeoilakapbetcmearesgbwihfngneajsgfaraneimdakhdceorcdemlybfgjjcetfmcurihliomfcdmcalmglcnhdmpbbvnrvpgdlphochfgnobdbieiulxcamebdxbofljoloahkpdthi")
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.makeSmallestPalindrome(",y,e,k,c,z,c,v,p,r,f,c,u,o,q,m,s,r,p,v,b,a,e,p,g,b,t,m,b,r,d,l,c,o,y,p,k,e,b,b,z,s,h,k,k,v,u,a,q,k,d,r,n,j,s,u,r,h,q,i,x,a,o,r,p,r,k,m,k,d,u,t,m,j,j,k,e,q,i,h,q,g,f,p,o,m,v,j,n,e,q,k,p,s,g,z,k,w,p,o,x,d,i,e,d,c,z,e,j,n,p,h,l,e,c,d,h,r,l,m,v,c,w,a,k,y,b,x,z,h,o,h,q,h,d,d,h,g,t,g,j,i,k,b,a,x,f,a,x,k,t,z,y,i,h,f,s,j,t,i,k,a,y,c,p,t,f,g,e,u,c,j,n,e,n,g,a,v,x,d,l,r,s,t,a,o,w,j,t,f,i,c,d,u,m,j,g,c,z,w,d,f,k,j,t,x,i,e,q,n,z,z,y,b,a,p,o,w,z,t,n,r,w,i,q,a,l,x,t,w,q,k,z,x,g,e,o,p,w,g,d,i,j,o,e,b,t,c,y,p,n,l,z,z,j,t,t,i,y,y,f,e,u,y,g,f,l,i,f,w,g,o,u,d,e,f,g,a,n,i,z,h,v,t,s,p,s,t,z,z,j,p,s,a,z,d,i,o,b,y,p,y,a,d,s,i,h,t,t,p,u,u,i,q,y,s,p,s,l,m,n,s,b,l,z,o,g,c,c,h,i,l,q,r,b,m,g,w,o,v,o,m,y,n,k,i,h,e,r,g,m,m,i,a,y,i,s,o,k,x,d,u,e,u,i,c,z,y,a,r,a,c,n,h,q,h,n,p,x,z,t,q,c,y,d,a,j,j,z,i,h,r,l,d,n,d,g,s,g,v,r,i,i,j,b,m,p,u,q,i,q,s,k,e,x,c,a,n,n,n,h,d,i,n,s,t,o,u,n,y,f,g,y,d,o,e,d,e,b,i,p,a,u,e,g,n,l,p,e,k,a,s,g,j,j,i,g,a,v,m,u,u,t,a,g,n,u,z,i,t,o,q,o,x,b,v,c,a,c,y,u,o,n,v,x,f,s,r,b,o,i,k,z,p,u,j,j,c,t,g,b,j,m,b,p,w,j,e,k,s,n,y,z,w,k,u,t,n,z,d,m,y,b,h,l,p,q,l,e,z,s,s,j,p,m,v,z,l,k,p,k,k,p,r,i,x,o,i,c,o,l,i,k,d,a,g,r,k,u,n,r,k,d,l,p,h,p,u,k,q,q,j,c,j,l,x,r,v,c,x,a,m,o,w,d,q,o,c,f,j,k,a,q,m,t,h,c,q,u,f,k,k,g,u,y,f,u,t,w,x,y,f,p,w,k,f,r,p,s,f,t,b,g,q,b,s,x,y,n,h,s,y,d,u,x,e,s,j,y,b,y,k,e,c,m,b,d,j,m,y,g,m,r,r,t,p,i,n,o,f,j,h,s,t,y,q,w,p,o,x,n,t,o,c,r,r,v,r,c,z,z,b,w,b,j,a,o,o,c,g,z,z,a,j,a,s,n,y,v,k,h,g,u,i,u,v,m,n,k,n,u,g,t,y,i,w,f,r,p,l,c,m,j,x,h,f,a,u,u,m,j,b,f,d,h,n,n,x,y,y,e,i,q,b,u,i,z,h,z,d,e,u,y,b,s,u,q,m,c,f,m,e,r,j,i,e,x,c,e,c,c,m,d,d,a,f,w,o,j,v,h,i,r,v,q,t,r,s,f,o,w,t,i,g,s,c,s,u,t,h,b,e,b,c,w,g,v,u,a,e,i,k,h,d,l,f,p,p,k,q,m,n,h,s,u,u,n,x,j,l,p,a,g,b,q,f,h,i,d,h,p,s,l,x,q,m,n,b,w,b,g,d,i,w,y,p,t,n,z,d,i,j,q,m,k,l,i,e,v,n,h,v,m,z,o,x,b,x,e,i,l,c,w,p,x,w,n,k,m,c,a,k,q,x,g,b,v,d,y,v,t,l,b,s,o,b,w,u,o,d,r,v,z,z,"), "yekcdcupbfcblqmsdpbbaekabmkbrdlcclieebboshkhnuaikdmnjidrhqixaidgbkbkdqtljjhdihfqbfaoljjneqkhngqkppfldhedcaejgpcbebdhrlcsciakobsrhohqhddhgtfaddbaceaxeijrehfcjqikaycedfgeicbneegavndhdfbamujafhcdmcjgcfwdfkgtniemnuiubakownsajaiqacooajbwbgecpvgdcjoebocwpnlshjfoiipfermgflidbgcedebganexhdtshntxsbpgatdiobfkwadsihttfuugkkfpqchnmbakjfcchdlomamcvovljcjkihepgmldariskkgadeiicciaracnhkhklxvmpcsdaejqihhbdmdgngukiijbmkejipbkebcacjjhdikiobrnffgndoecabibaoegnipekaagjjigagijjgaakepingeoabibaceodngffnrboikidhjjcacbekbpijekmbjiikugngdmdbhhiqjeadscpmvxlkhkhncaraicciiedagkksiradlmgpehikjcjlvovcmamoldhccfjkabmnhcqpfkkguuftthisdawkfboidtagpbsxtnhstdhxenagbedecgbdilfgmrefpiiofjhslnpwcobeojcdgvpcegbwbjaoocaqiajasnwokabuiunmeintgkfdwfcgjcmdchfajumabfdhdnvageenbciegfdecyakiqjcfherjiexaecabddaftghddhqhohrsbokaicsclrhdbebcpgjeacdehdlfppkqgnhkqenjjloafbqfhidhjjltqdkbkbgdiaxiqhrdijnmdkiaunhkhsobbeeilccldrbkmbakeabbpdsmqlbcfbpucdckey")
34
+ }
35
+
36
+ }
lexicographically_smallest_string_after_a_swap/haskell_tests/Main.hs ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ getSmallestString :: String -> String
7
+ getSmallestString s = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (getSmallestString \"45320 \")," "43520" (getSmallestString "45320"))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (getSmallestString \"001 \")," "001" (getSmallestString "001"))
18
+
19
+
20
+ -- Grouping test cases
21
+ tests :: Test
22
+ tests = TestList [TestLabel "Test1" test1]
23
+
24
+ -- Running the tests
25
+ main :: IO Counts
26
+ main = runTestTT tests
lexicographically_smallest_string_after_a_swap/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("45320", getSmallestString("45320"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("001", getSmallestString("001"));
18
+ }
19
+
20
+ }
lexicographically_smallest_string_after_a_swap/meta.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 3484,
3
+ "name": "lexicographically_smallest_string_after_a_swap",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap/",
6
+ "date": "2024-07-07 00:00:00",
7
+ "task_description": "Given a string `s` containing only digits, return the lexicographically smallest string that can be obtained after swapping **adjacent** digits in `s` with the same **parity** at most **once**. Digits have the same parity if both are odd or both are even. For example, 5 and 9, as well as 2 and 4, have the same parity, while 6 and 9 do not. **Example 1:** **Input:** s = \"45320\" **Output:** \"43520\" **Explanation: ** `s[1] == '5'` and `s[2] == '3'` both have the same parity, and swapping them results in the lexicographically smallest string. **Example 2:** **Input:** s = \"001\" **Output:** \"001\" **Explanation:** There is no need to perform a swap because `s` is already the lexicographically smallest. **Constraints:** `2 <= s.length <= 100` `s` consists only of digits.",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"45320\"",
12
+ "output": "\"43520\" "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"001\"",
17
+ "output": "\"001\" "
18
+ }
19
+ ],
20
+ "private_test_cases": [],
21
+ "haskell_template": "getSmallestString :: String -> String\ngetSmallestString s ",
22
+ "ocaml_template": "let getSmallestString (s: string) : string = ",
23
+ "scala_template": "def getSmallestString(s: String): String = { \n \n}",
24
+ "java_template": "class Solution {\n public String getSmallestString(String s) {\n \n }\n}",
25
+ "python_template": "class Solution(object):\n def getSmallestString(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
26
+ }
lexicographically_smallest_string_after_a_swap/ocaml_tests/main.ml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let getSmallestString (s: string) : string = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal "43520" (getSmallestString "45320")
13
+
14
+ let test2 _ = assert_equal "001" (getSmallestString "001")
15
+
16
+
17
+ (* Grouping test cases *)
18
+ let suite = "Test Suite for getSmallestString" >::: [
19
+
20
+ "test1" >:: test1;
21
+ "test2" >:: test2;
22
+ ]
23
+
24
+
25
+ (* Running the tests *)
26
+ let () = run_test_tt_main suite
27
+ end
lexicographically_smallest_string_after_a_swap/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.getSmallestString("45320"), "43520")
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.getSmallestString("001"), "001")
10
+ }
11
+
12
+ }
lexicographically_smallest_string_after_substring_operation/haskell_tests/Main.hs ADDED
The diff for this file is too large to render. See raw diff
 
lexicographically_smallest_string_after_substring_operation/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("cbabc", smallestString("cbabc"));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals("aa", smallestString("aa"));
18
+ }
19
+ @Test
20
+ public void test3() {
21
+ assertEquals("acbbc", smallestString("acbbc"));
22
+ }
23
+ @Test
24
+ public void test4() {
25
+ assertEquals("leetcode", smallestString("leetcode"));
26
+ }
27
+
28
+ }
lexicographically_smallest_string_after_substring_operation/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
lexicographically_smallest_string_after_substring_operation/ocaml_tests/main.ml ADDED
The diff for this file is too large to render. See raw diff
 
lexicographically_smallest_string_after_substring_operation/scala_tests/MySuite.scala ADDED
The diff for this file is too large to render. See raw diff
 
longest_alternating_subarray/haskell_tests/Main.hs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main where
3
+ import Test.HUnit
4
+
5
+ --Program start
6
+ alternatingSubarray :: [Int] -> Int
7
+ alternatingSubarray nums = undefined
8
+
9
+ --Program end
10
+
11
+ -- Test cases
12
+
13
+ test1 :: Test
14
+ test1 = TestCase (assertEqual "for (alternatingSubarray [2,3,4,3,4])," 4 (alternatingSubarray [2,3,4,3,4]))
15
+
16
+ test2 :: Test
17
+ test2 = TestCase (assertEqual "for (alternatingSubarray [4,5,6])," 2 (alternatingSubarray [4,5,6]))
18
+
19
+ test3 :: Test
20
+ test3 = TestCase (assertEqual "for (alternatingSubarray [54, 16, 32, 95, 67, 55, 86, 56, 31, 70, 16, 68, 90, 20, 43, 33, 67, 50, 75, 12, 55, 63, 26, 45, 31, 55, 17, 20, 83, 34, 63, 51, 82, 103, 88, 88, 8, 66, 76, 85, 93, 24, 4, 70, 5, 40, 46, 99, 88, 88, 8, 40, 58, 22, 39, 37, 39, 92, 29, 26, 44, 90, 38, 15, 48, 77, 76, 10, 96, 7, 26, 7, 95, 93])," (-1) (alternatingSubarray [54, 16, 32, 95, 67, 55, 86, 56, 31, 70, 16, 68, 90, 20, 43, 33, 67, 50, 75, 12, 55, 63, 26, 45, 31, 55, 17, 20, 83, 34, 63, 51, 82, 103, 88, 88, 8, 66, 76, 85, 93, 24, 4, 70, 5, 40, 46, 99, 88, 88, 8, 40, 58, 22, 39, 37, 39, 92, 29, 26, 44, 90, 38, 15, 48, 77, 76, 10, 96, 7, 26, 7, 95, 93]))
21
+
22
+ test4 :: Test
23
+ test4 = TestCase (assertEqual "for (alternatingSubarray [62, 77, 25, 40, 7, 16, 33, 76, 103, 72, 89, 50, 18, 58, 45, 28, 50, 88, 43, 65, 46, 100, 29, 65, 27, 29, 25, 8, 2, 33, 62, 34, 14, 20, 20, 40, 87, 75, 49, 53, 65, 87, 30, 100, 38, 9, 72, 86, 44, 10, 41, 53, 92, 99, 102, 14, 47, 34])," (-1) (alternatingSubarray [62, 77, 25, 40, 7, 16, 33, 76, 103, 72, 89, 50, 18, 58, 45, 28, 50, 88, 43, 65, 46, 100, 29, 65, 27, 29, 25, 8, 2, 33, 62, 34, 14, 20, 20, 40, 87, 75, 49, 53, 65, 87, 30, 100, 38, 9, 72, 86, 44, 10, 41, 53, 92, 99, 102, 14, 47, 34]))
24
+
25
+ test5 :: Test
26
+ test5 = TestCase (assertEqual "for (alternatingSubarray [50, 30, 88, 101, 99, 23, 27, 91, 21])," (-1) (alternatingSubarray [50, 30, 88, 101, 99, 23, 27, 91, 21]))
27
+
28
+ test6 :: Test
29
+ test6 = TestCase (assertEqual "for (alternatingSubarray [3, 23, 16, 46])," (-1) (alternatingSubarray [3, 23, 16, 46]))
30
+
31
+ test7 :: Test
32
+ test7 = TestCase (assertEqual "for (alternatingSubarray [38, 73, 92, 36, 95, 99, 83, 14, 95, 4, 91, 89, 82, 62, 22, 40, 102, 25, 45, 88, 60, 80, 36, 104, 71, 28, 39, 44, 44, 38, 65, 14, 29, 43, 17, 18, 22, 79, 39, 98, 102, 55, 81, 25, 104, 60, 6])," 2 (alternatingSubarray [38, 73, 92, 36, 95, 99, 83, 14, 95, 4, 91, 89, 82, 62, 22, 40, 102, 25, 45, 88, 60, 80, 36, 104, 71, 28, 39, 44, 44, 38, 65, 14, 29, 43, 17, 18, 22, 79, 39, 98, 102, 55, 81, 25, 104, 60, 6]))
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
longest_alternating_subarray/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(4, alternatingSubarray(Arrays.asList(2,3,4,3,4)));
14
+ }
15
+ @Test
16
+ public void test2() {
17
+ assertEquals(2, alternatingSubarray(Arrays.asList(4,5,6)));
18
+ }
19
+
20
+ }
longest_alternating_subarray/meta.json ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2870,
3
+ "name": "longest_alternating_subarray",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/longest-alternating-subarray/",
6
+ "date": "2023-06-24 00:00:00",
7
+ "task_description": "You are given a **0-indexed** integer array `nums`. A subarray `s` of length `m` is called **alternating** if: `m` is greater than `1`. `s1 = s0 + 1`. The **0-indexed** subarray `s` looks like `[s0, s1, s0, s1,...,s(m-1) % 2]`. In other words, `s1 - s0 = 1`, `s2 - s1 = -1`, `s3 - s2 = 1`, `s4 - s3 = -1`, and so on up to `s[m - 1] - s[m - 2] = (-1)m`. Return _the maximum length of all **alternating** subarrays present in _`nums` _or _`-1`_ if no such subarray exists__._ A subarray is a contiguous **non-empty** sequence of elements within an array. **Example 1:** **Input:** nums = [2,3,4,3,4] **Output:** 4 **Explanation:** The alternating subarrays are `[2, 3]`, `[3,4]`, `[3,4,3]`, and `[3,4,3,4]`. The longest of these is `[3,4,3,4]`, which is of length 4. **Example 2:** **Input:** nums = [4,5,6] **Output:** 2 **Explanation:** `[4,5]` and `[5,6]` are the only two alternating subarrays. They are both of length 2. **Constraints:** `2 <= nums.length <= 100` `1 <= nums[i] <= 104`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [2,3,4,3,4]",
12
+ "output": "4 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [4,5,6]",
17
+ "output": "2 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ 54,
24
+ 16,
25
+ 32,
26
+ 95,
27
+ 67,
28
+ 55,
29
+ 86,
30
+ 56,
31
+ 31,
32
+ 70,
33
+ 16,
34
+ 68,
35
+ 90,
36
+ 20,
37
+ 43,
38
+ 33,
39
+ 67,
40
+ 50,
41
+ 75,
42
+ 12,
43
+ 55,
44
+ 63,
45
+ 26,
46
+ 45,
47
+ 31,
48
+ 55,
49
+ 17,
50
+ 20,
51
+ 83,
52
+ 34,
53
+ 63,
54
+ 51,
55
+ 82,
56
+ 103,
57
+ 88,
58
+ 88,
59
+ 8,
60
+ 66,
61
+ 76,
62
+ 85,
63
+ 93,
64
+ 24,
65
+ 4,
66
+ 70,
67
+ 5,
68
+ 40,
69
+ 46,
70
+ 99,
71
+ 88,
72
+ 88,
73
+ 8,
74
+ 40,
75
+ 58,
76
+ 22,
77
+ 39,
78
+ 37,
79
+ 39,
80
+ 92,
81
+ 29,
82
+ 26,
83
+ 44,
84
+ 90,
85
+ 38,
86
+ 15,
87
+ 48,
88
+ 77,
89
+ 76,
90
+ 10,
91
+ 96,
92
+ 7,
93
+ 26,
94
+ 7,
95
+ 95,
96
+ 93
97
+ ],
98
+ "output": -1
99
+ },
100
+ {
101
+ "input": [
102
+ 62,
103
+ 77,
104
+ 25,
105
+ 40,
106
+ 7,
107
+ 16,
108
+ 33,
109
+ 76,
110
+ 103,
111
+ 72,
112
+ 89,
113
+ 50,
114
+ 18,
115
+ 58,
116
+ 45,
117
+ 28,
118
+ 50,
119
+ 88,
120
+ 43,
121
+ 65,
122
+ 46,
123
+ 100,
124
+ 29,
125
+ 65,
126
+ 27,
127
+ 29,
128
+ 25,
129
+ 8,
130
+ 2,
131
+ 33,
132
+ 62,
133
+ 34,
134
+ 14,
135
+ 20,
136
+ 20,
137
+ 40,
138
+ 87,
139
+ 75,
140
+ 49,
141
+ 53,
142
+ 65,
143
+ 87,
144
+ 30,
145
+ 100,
146
+ 38,
147
+ 9,
148
+ 72,
149
+ 86,
150
+ 44,
151
+ 10,
152
+ 41,
153
+ 53,
154
+ 92,
155
+ 99,
156
+ 102,
157
+ 14,
158
+ 47,
159
+ 34
160
+ ],
161
+ "output": -1
162
+ },
163
+ {
164
+ "input": [
165
+ 50,
166
+ 30,
167
+ 88,
168
+ 101,
169
+ 99,
170
+ 23,
171
+ 27,
172
+ 91,
173
+ 21
174
+ ],
175
+ "output": -1
176
+ },
177
+ {
178
+ "input": [
179
+ 3,
180
+ 23,
181
+ 16,
182
+ 46
183
+ ],
184
+ "output": -1
185
+ },
186
+ {
187
+ "input": [
188
+ 38,
189
+ 73,
190
+ 92,
191
+ 36,
192
+ 95,
193
+ 99,
194
+ 83,
195
+ 14,
196
+ 95,
197
+ 4,
198
+ 91,
199
+ 89,
200
+ 82,
201
+ 62,
202
+ 22,
203
+ 40,
204
+ 102,
205
+ 25,
206
+ 45,
207
+ 88,
208
+ 60,
209
+ 80,
210
+ 36,
211
+ 104,
212
+ 71,
213
+ 28,
214
+ 39,
215
+ 44,
216
+ 44,
217
+ 38,
218
+ 65,
219
+ 14,
220
+ 29,
221
+ 43,
222
+ 17,
223
+ 18,
224
+ 22,
225
+ 79,
226
+ 39,
227
+ 98,
228
+ 102,
229
+ 55,
230
+ 81,
231
+ 25,
232
+ 104,
233
+ 60,
234
+ 6
235
+ ],
236
+ "output": 2
237
+ }
238
+ ],
239
+ "haskell_template": "alternatingSubarray :: [Int] -> Int\nalternatingSubarray nums ",
240
+ "ocaml_template": "let alternatingSubarray (nums: int list) : int = ",
241
+ "scala_template": "def alternatingSubarray(nums: List[Int]): Int = { \n \n}",
242
+ "java_template": "class Solution {\n public int alternatingSubarray(int[] nums) {\n \n }\n}",
243
+ "python_template": "class Solution(object):\n def alternatingSubarray(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
244
+ }
longest_alternating_subarray/ocaml_tests/main.ml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ module Main = struct
3
+ open OUnit2
4
+
5
+ (* Program start *)
6
+ let alternatingSubarray (nums: int list) : int = failwith "Not implemented"
7
+
8
+ (* Program end *)
9
+
10
+ (* Test cases *)
11
+
12
+ let test1 _ = assert_equal 4 (alternatingSubarray [2;3;4;3;4])
13
+
14
+ let test2 _ = assert_equal 2 (alternatingSubarray [4;5;6])
15
+
16
+ let test3 _ = assert_equal 2 (alternatingSubarray [54; 16; 32; 95; 67; 55; 86; 56; 31; 70; 16; 68; 90; 20; 43; 33; 67; 50; 75; 12; 55; 63; 26; 45; 31; 55; 17; 20; 83; 34; 63; 51; 82; 103; 88; 88; 8; 66; 76; 85; 93; 24; 4; 70; 5; 40; 46; 99; 88; 88; 8; 40; 58; 22; 39; 37; 39; 92; 29; 26; 44; 90; 38; 15; 48; 77; 76; 10; 96; 7; 26; 7; 95; 93])
17
+
18
+ let test4 _ = assert_equal 2 (alternatingSubarray [62; 77; 25; 40; 7; 16; 33; 76; 103; 72; 89; 50; 18; 58; 45; 28; 50; 88; 43; 65; 46; 100; 29; 65; 27; 29; 25; 8; 2; 33; 62; 34; 14; 20; 20; 40; 87; 75; 49; 53; 65; 87; 30; 100; 38; 9; 72; 86; 44; 10; 41; 53; 92; 99; 102; 14; 47; 34])
19
+
20
+ let test5 _ = assert_equal 2 (alternatingSubarray [50; 30; 88; 101; 99; 23; 27; 91; 21])
21
+
22
+ let test6 _ = assert_equal 2 (alternatingSubarray [3; 23; 16; 46])
23
+
24
+ let test7 _ = assert_equal 2 (alternatingSubarray [38; 73; 92; 36; 95; 99; 83; 14; 95; 4; 91; 89; 82; 62; 22; 40; 102; 25; 45; 88; 60; 80; 36; 104; 71; 28; 39; 44; 44; 38; 65; 14; 29; 43; 17; 18; 22; 79; 39; 98; 102; 55; 81; 25; 104; 60; 6])
25
+
26
+
27
+ (* Grouping test cases *)
28
+ let suite = "Test Suite for alternatingSubarray" >::: [
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
longest_alternating_subarray/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.alternatingSubarray(List(2,3,4,3,4)), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.alternatingSubarray(List(4,5,6)), 2)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.alternatingSubarray(54,16,32,95,67,55,86,56,31,70,16,68,90,20,43,33,67,50,75,12,55,63,26,45,31,55,17,20,83,34,63,51,82,103,88,88,8,66,76,85,93,24,4,70,5,40,46,99,88,88,8,40,58,22,39,37,39,92,29,26,44,90,38,15,48,77,76,10,96,7,26,7,95,93), -1)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.alternatingSubarray(62,77,25,40,7,16,33,76,103,72,89,50,18,58,45,28,50,88,43,65,46,100,29,65,27,29,25,8,2,33,62,34,14,20,20,40,87,75,49,53,65,87,30,100,38,9,72,86,44,10,41,53,92,99,102,14,47,34), -1)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.alternatingSubarray(50,30,88,101,99,23,27,91,21), -1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.alternatingSubarray(3,23,16,46), -1)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.alternatingSubarray(38,73,92,36,95,99,83,14,95,4,91,89,82,62,22,40,102,25,45,88,60,80,36,104,71,28,39,44,44,38,65,14,29,43,17,18,22,79,39,98,102,55,81,25,104,60,6), 2)
30
+ }
31
+
32
+ }
longest_binary_subsequence_less_than_or_equal_to_k/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 (longestSubsequence \"1001010 \" 5)," 5 (longestSubsequence "1001010" 5))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestSubsequence \"00101001 \" 1)," 6 (longestSubsequence "00101001" 1))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (longestSubsequence \"01100111100110100110100010011111000010000011100000011111111100001101110101001100000001001110100000001010110011100001011011011010001101111000000111101110011011100111011111110111101000011101000001001111110011110011000011110100100100001110111100011011011001100101011010001011110111100000011010011011010001001111000011000110010000010001000111110100100010010101101100001101101101000000001010000101111101101111100111001010101101101100101011001100111111101110101111001010111010000101110001011100101011010011100101011000010 \" 539443994)," 266 (longestSubsequence "01100111100110100110100010011111000010000011100000011111111100001101110101001100000001001110100000001010110011100001011011011010001101111000000111101110011011100111011111110111101000011101000001001111110011110011000011110100100100001110111100011011011001100101011010001011110111100000011010011011010001001111000011000110010000010001000111110100100010010101101100001101101101000000001010000101111101101111100111001010101101101100101011001100111111101110101111001010111010000101110001011100101011010011100101011000010" 539443994))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (longestSubsequence \"001011000100001010101110001110101001001001001001010001011000101111011101001100101110110001000001111000011000110000000110100110110010100001011111111011110000111011010000000001000011110110101100011111011010100000011110000101111010111111000111110110011100001000100011001101100110101010101110011010000101010110011100000011011001010110010111101000111100101101010010111001011011001100010101000001001011111000100110000101111011001111111110010101011001101110101111010110000101100110010010111010101100111010011101011110101101111110010100010111000100110101101010001100011011100100011010101100001011000010011110110001110001111001000001011010110101110000001000001000110100110001010101001100101110011001100010001100101010001000011001100101100001001110101001101111001001111100101000101010101010111110101011000000111111100011011110100000101001100111110100000111011100110010000001100010100011011101000010001011110111 \" 898134424)," 471 (longestSubsequence "001011000100001010101110001110101001001001001001010001011000101111011101001100101110110001000001111000011000110000000110100110110010100001011111111011110000111011010000000001000011110110101100011111011010100000011110000101111010111111000111110110011100001000100011001101100110101010101110011010000101010110011100000011011001010110010111101000111100101101010010111001011011001100010101000001001011111000100110000101111011001111111110010101011001101110101111010110000101100110010010111010101100111010011101011110101101111110010100010111000100110101101010001100011011100100011010101100001011000010011110110001110001111001000001011010110101110000001000001000110100110001010101001100101110011001100010001100101010001000011001100101100001001110101001101111001001111100101000101010101010111110101011000000111111100011011110100000101001100111110100000111011100110010000001100010100011011101000010001011110111" 898134424))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (longestSubsequence \"11011101100010010001111001100110010000100111001010000000001101111001110111011100011000101111110101001001111100101001010001111110010110101100110110010110101000001101000001011010100110111110001001111110011110000111111010111110111001110000001111011100000001000011110000001100010111000111100101111110000110000101001011011100110111111011011000010110100010011000101111000000110011001100101101010110000110010011111011000100001001100001000001001000111001100000000001110000001101101111100010100110001111111010000010000011001001010011101111011001000100100010000110000010101110000001010100101101011011110011100011110000110101101101100000000110100001001000100001101110110001110010100101110110101011001010110010100001001100111011000 \" 322144614)," 387 (longestSubsequence "11011101100010010001111001100110010000100111001010000000001101111001110111011100011000101111110101001001111100101001010001111110010110101100110110010110101000001101000001011010100110111110001001111110011110000111111010111110111001110000001111011100000001000011110000001100010111000111100101111110000110000101001011011100110111111011011000010110100010011000101111000000110011001100101101010110000110010011111011000100001001100001000001001000111001100000000001110000001101101111100010100110001111111010000010000011001001010011101111011001000100100010000110000010101110000001010100101101011011110011100011110000110101101101100000000110100001001000100001101110110001110010100101110110101011001010110010100001001100111011000" 322144614))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (longestSubsequence \"1101101100101111110011111100101000011010001000110001110000011010100001001011100011000101110101000000101011111011000101101011110100010011000100101011000000010111100010100000001111011101110111101010001001111111110111010010100011011100111101101000100111011011011101100100111001010110110000001001011100011010010100011011001011010100001001010111011010110110001 \" 22228029)," 189 (longestSubsequence "1101101100101111110011111100101000011010001000110001110000011010100001001011100011000101110101000000101011111011000101101011110100010011000100101011000000010111100010100000001111011101110111101010001001111111110111010010100011011100111101101000100111011011011101100100111001010110110000001001011100011010010100011011001011010100001001010111011010110110001" 22228029))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (longestSubsequence \"0101011011000001000101001111011111101000111110000110101011100001001011010011101101010010111001110000100011001001111101100010010001001111111110001111011101110101001100011110100111101110101100111111111100011000110000100001010010111000000111001010010000000000100100101001110111011101110011110001100111001001100001111010111000011000011010000111100011010110101010011101010101010011100111000011010110001101001000010100000010101000111010011100111110101100110101101001101001010010011001111101011111101100100001000000000101101110011111111111010111110010100101110000111011010000010011001001100110000010001010111010100111101011011100100110001011000010100000100011001001011101000110000100110100001010011000010000110111000100101101100110101010001101101101111111111111000001011101110 \" 938141866)," 403 (longestSubsequence "0101011011000001000101001111011111101000111110000110101011100001001011010011101101010010111001110000100011001001111101100010010001001111111110001111011101110101001100011110100111101110101100111111111100011000110000100001010010111000000111001010010000000000100100101001110111011101110011110001100111001001100001111010111000011000011010000111100011010110101010011101010101010011100111000011010110001101001000010100000010101000111010011100111110101100110101101001101001010010011001111101011111101100100001000000000101101110011111111111010111110010100101110000111011010000010011001001100110000010001010111010100111101011011100100110001011000010100000100011001001011101000110000100110100001010011000010000110111000100101101100110101010001101101101111111111111000001011101110" 938141866))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (longestSubsequence \"0100101010100000110101011101100100110011010101110000100111000001100010011010000010000111011010101111111100101001100010000000100111010111111001011111000010101100100101100001001100100010111101000111010100100000000100010101001100010100001110101101110001001000101101100000111010101000110001110100101100100011000010000110111110101000101110000001010101110100010110001001111000100010000111011101111111001111010000001101010010111001101000 \" 896186850)," 244 (longestSubsequence "0100101010100000110101011101100100110011010101110000100111000001100010011010000010000111011010101111111100101001100010000000100111010111111001011111000010101100100101100001001100100010111101000111010100100000000100010101001100010100001110101101110001001000101101100000111010101000110001110100101100100011000010000110111110101000101110000001010101110100010110001001111000100010000111011101111111001111010000001101010010111001101000" 896186850))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (longestSubsequence \"0100111010100101001101000111000101111111000111111110101100001000000101011101110001001101110111111000111110011001100101010110010110100000010010111010001010111100101101111001111101011001000111010100100100000010010011010001001011100000100011010111111110001011110111111001001010100100000011011010111101010101110000101000101101110101100110100000000011110011011101111011000101000000010100100001000000000000100110101011000111010111101110100110000000010111100100011110011010 \" 750151912)," 250 (longestSubsequence "0100111010100101001101000111000101111111000111111110101100001000000101011101110001001101110111111000111110011001100101010110010110100000010010111010001010111100101101111001111101011001000111010100100100000010010011010001001011100000100011010111111110001011110111111001001010100100000011011010111101010101110000101000101101110101100110100000000011110011011101111011000101000000010100100001000000000000100110101011000111010111101110100110000000010111100100011110011010" 750151912))
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]
42
+
43
+ -- Running the tests
44
+ main :: IO Counts
45
+ main = runTestTT tests
longest_binary_subsequence_less_than_or_equal_to_k/java_tests/Main.java ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import static org.junit.jupiter.api.Assertions.*;
3
+ import org.junit.jupiter.api.Test;
4
+ import java.util.List;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ public class Main {
8
+ //Program start
9
+
10
+ //Program end
11
+
12
+ @Test
13
+ public void test1() {
14
+ assertEquals(5, longestSubsequence("1001010", 5));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(6, longestSubsequence("00101001", 1));
19
+ }
20
+
21
+ }
longest_binary_subsequence_less_than_or_equal_to_k/meta.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2395,
3
+ "name": "longest_binary_subsequence_less_than_or_equal_to_k",
4
+ "difficulty": "Medium",
5
+ "link": "https://leetcode.com/problems/longest-binary-subsequence-less-than-or-equal-to-k/",
6
+ "date": "2022-06-12 00:00:00",
7
+ "task_description": "You are given a binary string `s` and a positive integer `k`. Return _the length of the **longest** subsequence of _`s`_ that makes up a **binary** number less than or equal to_ `k`. Note: The subsequence can contain **leading zeroes**. The empty string is considered to be equal to `0`. A **subsequence** is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. **Example 1:** ``` **Input:** s = \"1001010\", k = 5 **Output:** 5 **Explanation:** The longest subsequence of s that makes up a binary number less than or equal to 5 is \"00010\", as this number is equal to 2 in decimal. Note that \"00100\" and \"00101\" are also possible, which are equal to 4 and 5 in decimal, respectively. The length of this subsequence is 5, so 5 is returned. ``` **Example 2:** ``` **Input:** s = \"00101001\", k = 1 **Output:** 6 **Explanation:** \"000001\" is the longest subsequence of s that makes up a binary number less than or equal to 1, as this number is equal to 1 in decimal. The length of this subsequence is 6, so 6 is returned. ``` **Constraints:** `1 <= s.length <= 1000` `s[i]` is either `'0'` or `'1'`. `1 <= k <= 109`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "s = \"1001010\", k = 5",
12
+ "output": "5 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "s = \"00101001\", k = 1",
17
+ "output": "6 "
18
+ }
19
+ ],
20
+ "private_test_cases": [
21
+ {
22
+ "input": [
23
+ "\"01100111100110100110100010011111000010000011100000011111111100001101110101001100000001001110100000001010110011100001011011011010001101111000000111101110011011100111011111110111101000011101000001001111110011110011000011110100100100001110111100011011011001100101011010001011110111100000011010011011010001001111000011000110010000010001000111110100100010010101101100001101101101000000001010000101111101101111100111001010101101101100101011001100111111101110101111001010111010000101110001011100101011010011100101011000010\"",
24
+ 539443994
25
+ ],
26
+ "output": 266
27
+ },
28
+ {
29
+ "input": [
30
+ "\"001011000100001010101110001110101001001001001001010001011000101111011101001100101110110001000001111000011000110000000110100110110010100001011111111011110000111011010000000001000011110110101100011111011010100000011110000101111010111111000111110110011100001000100011001101100110101010101110011010000101010110011100000011011001010110010111101000111100101101010010111001011011001100010101000001001011111000100110000101111011001111111110010101011001101110101111010110000101100110010010111010101100111010011101011110101101111110010100010111000100110101101010001100011011100100011010101100001011000010011110110001110001111001000001011010110101110000001000001000110100110001010101001100101110011001100010001100101010001000011001100101100001001110101001101111001001111100101000101010101010111110101011000000111111100011011110100000101001100111110100000111011100110010000001100010100011011101000010001011110111\"",
31
+ 898134424
32
+ ],
33
+ "output": 471
34
+ },
35
+ {
36
+ "input": [
37
+ "\"11011101100010010001111001100110010000100111001010000000001101111001110111011100011000101111110101001001111100101001010001111110010110101100110110010110101000001101000001011010100110111110001001111110011110000111111010111110111001110000001111011100000001000011110000001100010111000111100101111110000110000101001011011100110111111011011000010110100010011000101111000000110011001100101101010110000110010011111011000100001001100001000001001000111001100000000001110000001101101111100010100110001111111010000010000011001001010011101111011001000100100010000110000010101110000001010100101101011011110011100011110000110101101101100000000110100001001000100001101110110001110010100101110110101011001010110010100001001100111011000\"",
38
+ 322144614
39
+ ],
40
+ "output": 387
41
+ },
42
+ {
43
+ "input": [
44
+ "\"1101101100101111110011111100101000011010001000110001110000011010100001001011100011000101110101000000101011111011000101101011110100010011000100101011000000010111100010100000001111011101110111101010001001111111110111010010100011011100111101101000100111011011011101100100111001010110110000001001011100011010010100011011001011010100001001010111011010110110001\"",
45
+ 22228029
46
+ ],
47
+ "output": 189
48
+ },
49
+ {
50
+ "input": [
51
+ "\"0101011011000001000101001111011111101000111110000110101011100001001011010011101101010010111001110000100011001001111101100010010001001111111110001111011101110101001100011110100111101110101100111111111100011000110000100001010010111000000111001010010000000000100100101001110111011101110011110001100111001001100001111010111000011000011010000111100011010110101010011101010101010011100111000011010110001101001000010100000010101000111010011100111110101100110101101001101001010010011001111101011111101100100001000000000101101110011111111111010111110010100101110000111011010000010011001001100110000010001010111010100111101011011100100110001011000010100000100011001001011101000110000100110100001010011000010000110111000100101101100110101010001101101101111111111111000001011101110\"",
52
+ 938141866
53
+ ],
54
+ "output": 403
55
+ },
56
+ {
57
+ "input": [
58
+ "\"0100101010100000110101011101100100110011010101110000100111000001100010011010000010000111011010101111111100101001100010000000100111010111111001011111000010101100100101100001001100100010111101000111010100100000000100010101001100010100001110101101110001001000101101100000111010101000110001110100101100100011000010000110111110101000101110000001010101110100010110001001111000100010000111011101111111001111010000001101010010111001101000\"",
59
+ 896186850
60
+ ],
61
+ "output": 244
62
+ },
63
+ {
64
+ "input": [
65
+ "\"0100111010100101001101000111000101111111000111111110101100001000000101011101110001001101110111111000111110011001100101010110010110100000010010111010001010111100101101111001111101011001000111010100100100000010010011010001001011100000100011010111111110001011110111111001001010100100000011011010111101010101110000101000101101110101100110100000000011110011011101111011000101000000010100100001000000000000100110101011000111010111101110100110000000010111100100011110011010\"",
66
+ 750151912
67
+ ],
68
+ "output": 250
69
+ }
70
+ ],
71
+ "haskell_template": "longestSubsequence :: String -> Int -> Int\nlongestSubsequence s k ",
72
+ "ocaml_template": "let longestSubsequence (s: string) (k: int) : int = ",
73
+ "scala_template": "def longestSubsequence(s: String,k: Int): Int = { \n \n}",
74
+ "java_template": "class Solution {\n public int longestSubsequence(String s, int k) {\n \n }\n}",
75
+ "python_template": "class Solution(object):\n def longestSubsequence(self, s, k):\n \"\"\"\n :type s: str\n :type k: int\n :rtype: int\n \"\"\"\n "
76
+ }
longest_binary_subsequence_less_than_or_equal_to_k/ocaml_tests/main.ml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (longestSubsequence "1001010" 5)
12
+
13
+ let test2 _ = assert_equal 6 (longestSubsequence "00101001" 1)
14
+
15
+ let test3 _ = assert_equal 266 (longestSubsequence "01100111100110100110100010011111000010000011100000011111111100001101110101001100000001001110100000001010110011100001011011011010001101111000000111101110011011100111011111110111101000011101000001001111110011110011000011110100100100001110111100011011011001100101011010001011110111100000011010011011010001001111000011000110010000010001000111110100100010010101101100001101101101000000001010000101111101101111100111001010101101101100101011001100111111101110101111001010111010000101110001011100101011010011100101011000010" 539443994)
16
+
17
+ let test4 _ = assert_equal 471 (longestSubsequence "001011000100001010101110001110101001001001001001010001011000101111011101001100101110110001000001111000011000110000000110100110110010100001011111111011110000111011010000000001000011110110101100011111011010100000011110000101111010111111000111110110011100001000100011001101100110101010101110011010000101010110011100000011011001010110010111101000111100101101010010111001011011001100010101000001001011111000100110000101111011001111111110010101011001101110101111010110000101100110010010111010101100111010011101011110101101111110010100010111000100110101101010001100011011100100011010101100001011000010011110110001110001111001000001011010110101110000001000001000110100110001010101001100101110011001100010001100101010001000011001100101100001001110101001101111001001111100101000101010101010111110101011000000111111100011011110100000101001100111110100000111011100110010000001100010100011011101000010001011110111" 898134424)
18
+
19
+ let test5 _ = assert_equal 387 (longestSubsequence "11011101100010010001111001100110010000100111001010000000001101111001110111011100011000101111110101001001111100101001010001111110010110101100110110010110101000001101000001011010100110111110001001111110011110000111111010111110111001110000001111011100000001000011110000001100010111000111100101111110000110000101001011011100110111111011011000010110100010011000101111000000110011001100101101010110000110010011111011000100001001100001000001001000111001100000000001110000001101101111100010100110001111111010000010000011001001010011101111011001000100100010000110000010101110000001010100101101011011110011100011110000110101101101100000000110100001001000100001101110110001110010100101110110101011001010110010100001001100111011000" 322144614)
20
+
21
+ let test6 _ = assert_equal 189 (longestSubsequence "1101101100101111110011111100101000011010001000110001110000011010100001001011100011000101110101000000101011111011000101101011110100010011000100101011000000010111100010100000001111011101110111101010001001111111110111010010100011011100111101101000100111011011011101100100111001010110110000001001011100011010010100011011001011010100001001010111011010110110001" 22228029)
22
+
23
+ let test7 _ = assert_equal 403 (longestSubsequence "0101011011000001000101001111011111101000111110000110101011100001001011010011101101010010111001110000100011001001111101100010010001001111111110001111011101110101001100011110100111101110101100111111111100011000110000100001010010111000000111001010010000000000100100101001110111011101110011110001100111001001100001111010111000011000011010000111100011010110101010011101010101010011100111000011010110001101001000010100000010101000111010011100111110101100110101101001101001010010011001111101011111101100100001000000000101101110011111111111010111110010100101110000111011010000010011001001100110000010001010111010100111101011011100100110001011000010100000100011001001011101000110000100110100001010011000010000110111000100101101100110101010001101101101111111111111000001011101110" 938141866)
24
+
25
+ let test8 _ = assert_equal 244 (longestSubsequence "0100101010100000110101011101100100110011010101110000100111000001100010011010000010000111011010101111111100101001100010000000100111010111111001011111000010101100100101100001001100100010111101000111010100100000000100010101001100010100001110101101110001001000101101100000111010101000110001110100101100100011000010000110111110101000101110000001010101110100010110001001111000100010000111011101111111001111010000001101010010111001101000" 896186850)
26
+
27
+ let test9 _ = assert_equal 250 (longestSubsequence "0100111010100101001101000111000101111111000111111110101100001000000101011101110001001101110111111000111110011001100101010110010110100000010010111010001010111100101101111001111101011001000111010100100100000010010011010001001011100000100011010111111110001011110111111001001010100100000011011010111101010101110000101000101101110101100110100000000011110011011101111011000101000000010100100001000000000000100110101011000111010111101110100110000000010111100100011110011010" 750151912)
28
+
29
+
30
+ (* Grouping test cases *)
31
+ let suite = "Test Suite for longestSubsequence" >::: [
32
+
33
+ "test1" >:: test1;
34
+ "test2" >:: test2;
35
+ "test3" >:: test3;
36
+ "test4" >:: test4;
37
+ "test5" >:: test5;
38
+ "test6" >:: test6;
39
+ "test7" >:: test7;
40
+ "test8" >:: test8;
41
+ "test9" >:: test9;
42
+ ]
43
+
44
+
45
+ (* Running the tests *)
46
+ let () = run_test_tt_main suite
47
+ end
longest_binary_subsequence_less_than_or_equal_to_k/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestSubsequence("1001010",5), 5)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestSubsequence("00101001",1), 6)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.longestSubsequence("01100111100110100110100010011111000010000011100000011111111100001101110101001100000001001110100000001010110011100001011011011010001101111000000111101110011011100111011111110111101000011101000001001111110011110011000011110100100100001110111100011011011001100101011010001011110111100000011010011011010001001111000011000110010000010001000111110100100010010101101100001101101101000000001010000101111101101111100111001010101101101100101011001100111111101110101111001010111010000101110001011100101011010011100101011000010",539443994), 266)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.longestSubsequence("001011000100001010101110001110101001001001001001010001011000101111011101001100101110110001000001111000011000110000000110100110110010100001011111111011110000111011010000000001000011110110101100011111011010100000011110000101111010111111000111110110011100001000100011001101100110101010101110011010000101010110011100000011011001010110010111101000111100101101010010111001011011001100010101000001001011111000100110000101111011001111111110010101011001101110101111010110000101100110010010111010101100111010011101011110101101111110010100010111000100110101101010001100011011100100011010101100001011000010011110110001110001111001000001011010110101110000001000001000110100110001010101001100101110011001100010001100101010001000011001100101100001001110101001101111001001111100101000101010101010111110101011000000111111100011011110100000101001100111110100000111011100110010000001100010100011011101000010001011110111",898134424), 471)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.longestSubsequence("11011101100010010001111001100110010000100111001010000000001101111001110111011100011000101111110101001001111100101001010001111110010110101100110110010110101000001101000001011010100110111110001001111110011110000111111010111110111001110000001111011100000001000011110000001100010111000111100101111110000110000101001011011100110111111011011000010110100010011000101111000000110011001100101101010110000110010011111011000100001001100001000001001000111001100000000001110000001101101111100010100110001111111010000010000011001001010011101111011001000100100010000110000010101110000001010100101101011011110011100011110000110101101101100000000110100001001000100001101110110001110010100101110110101011001010110010100001001100111011000",322144614), 387)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.longestSubsequence("1101101100101111110011111100101000011010001000110001110000011010100001001011100011000101110101000000101011111011000101101011110100010011000100101011000000010111100010100000001111011101110111101010001001111111110111010010100011011100111101101000100111011011011101100100111001010110110000001001011100011010010100011011001011010100001001010111011010110110001",22228029), 189)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.longestSubsequence("0101011011000001000101001111011111101000111110000110101011100001001011010011101101010010111001110000100011001001111101100010010001001111111110001111011101110101001100011110100111101110101100111111111100011000110000100001010010111000000111001010010000000000100100101001110111011101110011110001100111001001100001111010111000011000011010000111100011010110101010011101010101010011100111000011010110001101001000010100000010101000111010011100111110101100110101101001101001010010011001111101011111101100100001000000000101101110011111111111010111110010100101110000111011010000010011001001100110000010001010111010100111101011011100100110001011000010100000100011001001011101000110000100110100001010011000010000110111000100101101100110101010001101101101111111111111000001011101110",938141866), 403)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.longestSubsequence("0100101010100000110101011101100100110011010101110000100111000001100010011010000010000111011010101111111100101001100010000000100111010111111001011111000010101100100101100001001100100010111101000111010100100000000100010101001100010100001110101101110001001000101101100000111010101000110001110100101100100011000010000110111110101000101110000001010101110100010110001001111000100010000111011101111111001111010000001101010010111001101000",896186850), 244)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.longestSubsequence("0100111010100101001101000111000101111111000111111110101100001000000101011101110001001101110111111000111110011001100101010110010110100000010010111010001010111100101101111001111101011001000111010100100100000010010011010001001011100000100011010111111110001011110111111001001010100100000011011010111101010101110000101000101101110101100110100000000011110011011101111011000101000000010100100001000000000000100110101011000111010111101110100110000000010111100100011110011010",750151912), 250)
38
+ }
39
+
40
+ }
longest_even_odd_subarray_with_threshold/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 (longestAlternatingSubarray [3,2,5,4] 5)," 3 (longestAlternatingSubarray [3,2,5,4] 5))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestAlternatingSubarray [1,2] 2)," 1 (longestAlternatingSubarray [1,2] 2))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (longestAlternatingSubarray [2,3,4,5] 4)," 3 (longestAlternatingSubarray [2,3,4,5] 4))
19
+
20
+ test4 :: Test
21
+ test4 = TestCase (assertEqual "for (longestAlternatingSubarray [53, 12, 16, 68, 39, 99, 81, 24, 65, 67, 59, 84, 17, 39, 42, 1, 87, 59, 34, 41] 60)," 2 (longestAlternatingSubarray [53, 12, 16, 68, 39, 99, 81, 24, 65, 67, 59, 84, 17, 39, 42, 1, 87, 59, 34, 41] 60))
22
+
23
+ test5 :: Test
24
+ test5 = TestCase (assertEqual "for (longestAlternatingSubarray [93, 15, 82, 51, 33, 7, 29, 37, 40, 29, 71, 75, 5, 63, 16, 29, 34, 16, 61, 96, 17, 76, 76, 19, 69, 70, 61, 14, 29, 10, 37] 16)," 1 (longestAlternatingSubarray [93, 15, 82, 51, 33, 7, 29, 37, 40, 29, 71, 75, 5, 63, 16, 29, 34, 16, 61, 96, 17, 76, 76, 19, 69, 70, 61, 14, 29, 10, 37] 16))
25
+
26
+ test6 :: Test
27
+ test6 = TestCase (assertEqual "for (longestAlternatingSubarray [5, 89, 86, 41, 61, 81, 6, 24, 48, 36, 58, 2, 76, 25, 18, 51, 75, 1, 51, 7, 43, 9, 30, 30, 41, 41, 11, 79] 49)," 2 (longestAlternatingSubarray [5, 89, 86, 41, 61, 81, 6, 24, 48, 36, 58, 2, 76, 25, 18, 51, 75, 1, 51, 7, 43, 9, 30, 30, 41, 41, 11, 79] 49))
28
+
29
+ test7 :: Test
30
+ test7 = TestCase (assertEqual "for (longestAlternatingSubarray [76, 86, 22, 69, 47, 36, 46, 12, 56, 6, 77, 30, 77, 36, 65, 10, 32, 48, 62, 75, 58, 65, 39, 3, 9, 21, 24, 68, 93, 6, 34, 80, 84, 5, 4, 70, 5, 46, 30] 79)," 7 (longestAlternatingSubarray [76, 86, 22, 69, 47, 36, 46, 12, 56, 6, 77, 30, 77, 36, 65, 10, 32, 48, 62, 75, 58, 65, 39, 3, 9, 21, 24, 68, 93, 6, 34, 80, 84, 5, 4, 70, 5, 46, 30] 79))
31
+
32
+ test8 :: Test
33
+ test8 = TestCase (assertEqual "for (longestAlternatingSubarray [7, 49, 35, 59, 41, 43, 27, 60, 13, 47, 39, 16, 56, 74, 76, 87, 17, 61, 30, 9, 99, 99, 42, 25, 18, 95, 56, 86, 41, 87, 53, 87, 32, 25, 87, 62, 58, 60, 71, 74, 16, 67, 76, 85, 78, 23, 10, 4, 96, 96, 57, 46] 45)," 3 (longestAlternatingSubarray [7, 49, 35, 59, 41, 43, 27, 60, 13, 47, 39, 16, 56, 74, 76, 87, 17, 61, 30, 9, 99, 99, 42, 25, 18, 95, 56, 86, 41, 87, 53, 87, 32, 25, 87, 62, 58, 60, 71, 74, 16, 67, 76, 85, 78, 23, 10, 4, 96, 96, 57, 46] 45))
34
+
35
+ test9 :: Test
36
+ test9 = TestCase (assertEqual "for (longestAlternatingSubarray [50, 2, 70, 95, 9, 66, 2, 82, 95, 84, 33, 65, 44, 66, 83, 17, 1, 29, 92, 8, 96, 100, 6, 74, 96, 71, 78, 73, 53, 9, 45, 79, 90, 57, 72, 49, 87, 79, 80, 67, 50, 68, 89, 15, 89, 39, 45, 51, 52, 59, 21, 12, 87, 74, 52, 30, 47, 23, 23, 56, 62, 13, 16, 51, 96, 64, 18, 12, 71, 22, 39, 95, 48, 4, 39, 42, 78, 59, 11] 39)," 2 (longestAlternatingSubarray [50, 2, 70, 95, 9, 66, 2, 82, 95, 84, 33, 65, 44, 66, 83, 17, 1, 29, 92, 8, 96, 100, 6, 74, 96, 71, 78, 73, 53, 9, 45, 79, 90, 57, 72, 49, 87, 79, 80, 67, 50, 68, 89, 15, 89, 39, 45, 51, 52, 59, 21, 12, 87, 74, 52, 30, 47, 23, 23, 56, 62, 13, 16, 51, 96, 64, 18, 12, 71, 22, 39, 95, 48, 4, 39, 42, 78, 59, 11] 39))
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_even_odd_subarray_with_threshold/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, longestAlternatingSubarray(new ArrayList<>(Arrays.asList(3,2,5,4)), 5));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(1, longestAlternatingSubarray(new ArrayList<>(Arrays.asList(1,2)), 2));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(3, longestAlternatingSubarray(new ArrayList<>(Arrays.asList(2,3,4,5)), 4));
23
+ }
24
+
25
+ }
longest_even_odd_subarray_with_threshold/meta.json ADDED
@@ -0,0 +1,631 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2866,
3
+ "name": "longest_even_odd_subarray_with_threshold",
4
+ "difficulty": "Easy",
5
+ "link": "https://leetcode.com/problems/longest-even-odd-subarray-with-threshold/",
6
+ "date": "2023-06-25 00:00:00",
7
+ "task_description": "You are given a **0-indexed** integer array `nums` and an integer `threshold`. Find the length of the **longest subarray** of `nums` starting at index `l` and ending at index `r` `(0 <= l <= r < nums.length)` that satisfies the following conditions: `nums[l] % 2 == 0` For all indices `i` in the range `[l, r - 1]`, `nums[i] % 2 != nums[i + 1] % 2` For all indices `i` in the range `[l, r]`, `nums[i] <= threshold` Return _an integer denoting the length of the longest such subarray._ **Note:** A **subarray** is a contiguous non-empty sequence of elements within an array. **Example 1:** ``` **Input:** nums = [3,2,5,4], threshold = 5 **Output:** 3 **Explanation:** In this example, we can select the subarray that starts at l = 1 and ends at r = 3 => [2,5,4]. This subarray satisfies the conditions. Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length. ``` **Example 2:** ``` **Input:** nums = [1,2], threshold = 2 **Output:** 1 **Explanation:** In this example, we can select the subarray that starts at l = 1 and ends at r = 1 => [2]. It satisfies all the conditions and we can show that 1 is the maximum possible achievable length. ``` **Example 3:** ``` **Input:** nums = [2,3,4,5], threshold = 4 **Output:** 3 **Explanation:** In this example, we can select the subarray that starts at l = 0 and ends at r = 2 => [2,3,4]. It satisfies all the conditions. Hence, the answer is the length of the subarray, 3. We can show that 3 is the maximum possible achievable length. ``` **Constraints:** `1 <= nums.length <= 100 ` `1 <= nums[i] <= 100 ` `1 <= threshold <= 100`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [3,2,5,4], threshold = 5",
12
+ "output": "3 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [1,2], threshold = 2",
17
+ "output": "1 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [2,3,4,5], threshold = 4",
22
+ "output": "3 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ [
29
+ 53,
30
+ 12,
31
+ 16,
32
+ 68,
33
+ 39,
34
+ 99,
35
+ 81,
36
+ 24,
37
+ 65,
38
+ 67,
39
+ 59,
40
+ 84,
41
+ 17,
42
+ 39,
43
+ 42,
44
+ 1,
45
+ 87,
46
+ 59,
47
+ 34,
48
+ 41
49
+ ],
50
+ 60
51
+ ],
52
+ "output": 2
53
+ },
54
+ {
55
+ "input": [
56
+ [
57
+ 93,
58
+ 15,
59
+ 82,
60
+ 51,
61
+ 33,
62
+ 7,
63
+ 29,
64
+ 37,
65
+ 40,
66
+ 29,
67
+ 71,
68
+ 75,
69
+ 5,
70
+ 63,
71
+ 16,
72
+ 29,
73
+ 34,
74
+ 16,
75
+ 61,
76
+ 96,
77
+ 17,
78
+ 76,
79
+ 76,
80
+ 19,
81
+ 69,
82
+ 70,
83
+ 61,
84
+ 14,
85
+ 29,
86
+ 10,
87
+ 37
88
+ ],
89
+ 16
90
+ ],
91
+ "output": 1
92
+ },
93
+ {
94
+ "input": [
95
+ [
96
+ 5,
97
+ 89,
98
+ 86,
99
+ 41,
100
+ 61,
101
+ 81,
102
+ 6,
103
+ 24,
104
+ 48,
105
+ 36,
106
+ 58,
107
+ 2,
108
+ 76,
109
+ 25,
110
+ 18,
111
+ 51,
112
+ 75,
113
+ 1,
114
+ 51,
115
+ 7,
116
+ 43,
117
+ 9,
118
+ 30,
119
+ 30,
120
+ 41,
121
+ 41,
122
+ 11,
123
+ 79
124
+ ],
125
+ 49
126
+ ],
127
+ "output": 2
128
+ },
129
+ {
130
+ "input": [
131
+ [
132
+ 76,
133
+ 86,
134
+ 22,
135
+ 69,
136
+ 47,
137
+ 36,
138
+ 46,
139
+ 12,
140
+ 56,
141
+ 6,
142
+ 77,
143
+ 30,
144
+ 77,
145
+ 36,
146
+ 65,
147
+ 10,
148
+ 32,
149
+ 48,
150
+ 62,
151
+ 75,
152
+ 58,
153
+ 65,
154
+ 39,
155
+ 3,
156
+ 9,
157
+ 21,
158
+ 24,
159
+ 68,
160
+ 93,
161
+ 6,
162
+ 34,
163
+ 80,
164
+ 84,
165
+ 5,
166
+ 4,
167
+ 70,
168
+ 5,
169
+ 46,
170
+ 30
171
+ ],
172
+ 79
173
+ ],
174
+ "output": 7
175
+ },
176
+ {
177
+ "input": [
178
+ [
179
+ 7,
180
+ 49,
181
+ 35,
182
+ 59,
183
+ 41,
184
+ 43,
185
+ 27,
186
+ 60,
187
+ 13,
188
+ 47,
189
+ 39,
190
+ 16,
191
+ 56,
192
+ 74,
193
+ 76,
194
+ 87,
195
+ 17,
196
+ 61,
197
+ 30,
198
+ 9,
199
+ 99,
200
+ 99,
201
+ 42,
202
+ 25,
203
+ 18,
204
+ 95,
205
+ 56,
206
+ 86,
207
+ 41,
208
+ 87,
209
+ 53,
210
+ 87,
211
+ 32,
212
+ 25,
213
+ 87,
214
+ 62,
215
+ 58,
216
+ 60,
217
+ 71,
218
+ 74,
219
+ 16,
220
+ 67,
221
+ 76,
222
+ 85,
223
+ 78,
224
+ 23,
225
+ 10,
226
+ 4,
227
+ 96,
228
+ 96,
229
+ 57,
230
+ 46
231
+ ],
232
+ 45
233
+ ],
234
+ "output": 3
235
+ },
236
+ {
237
+ "input": [
238
+ [
239
+ 50,
240
+ 2,
241
+ 70,
242
+ 95,
243
+ 9,
244
+ 66,
245
+ 2,
246
+ 82,
247
+ 95,
248
+ 84,
249
+ 33,
250
+ 65,
251
+ 44,
252
+ 66,
253
+ 83,
254
+ 17,
255
+ 1,
256
+ 29,
257
+ 92,
258
+ 8,
259
+ 96,
260
+ 100,
261
+ 6,
262
+ 74,
263
+ 96,
264
+ 71,
265
+ 78,
266
+ 73,
267
+ 53,
268
+ 9,
269
+ 45,
270
+ 79,
271
+ 90,
272
+ 57,
273
+ 72,
274
+ 49,
275
+ 87,
276
+ 79,
277
+ 80,
278
+ 67,
279
+ 50,
280
+ 68,
281
+ 89,
282
+ 15,
283
+ 89,
284
+ 39,
285
+ 45,
286
+ 51,
287
+ 52,
288
+ 59,
289
+ 21,
290
+ 12,
291
+ 87,
292
+ 74,
293
+ 52,
294
+ 30,
295
+ 47,
296
+ 23,
297
+ 23,
298
+ 56,
299
+ 62,
300
+ 13,
301
+ 16,
302
+ 51,
303
+ 96,
304
+ 64,
305
+ 18,
306
+ 12,
307
+ 71,
308
+ 22,
309
+ 39,
310
+ 95,
311
+ 48,
312
+ 4,
313
+ 39,
314
+ 42,
315
+ 78,
316
+ 59,
317
+ 11
318
+ ],
319
+ 39
320
+ ],
321
+ "output": 2
322
+ },
323
+ {
324
+ "input": [
325
+ [
326
+ 99,
327
+ 70,
328
+ 43,
329
+ 46,
330
+ 94,
331
+ 9,
332
+ 54,
333
+ 6,
334
+ 6,
335
+ 71,
336
+ 16,
337
+ 38,
338
+ 38,
339
+ 77,
340
+ 57,
341
+ 96,
342
+ 23,
343
+ 71,
344
+ 62,
345
+ 12,
346
+ 72,
347
+ 32,
348
+ 67,
349
+ 64,
350
+ 69,
351
+ 19,
352
+ 40,
353
+ 58,
354
+ 52,
355
+ 72,
356
+ 53,
357
+ 3,
358
+ 38,
359
+ 68,
360
+ 46,
361
+ 17,
362
+ 20,
363
+ 13,
364
+ 96,
365
+ 75,
366
+ 17,
367
+ 31,
368
+ 14,
369
+ 31,
370
+ 87,
371
+ 2,
372
+ 51,
373
+ 1,
374
+ 42,
375
+ 11
376
+ ],
377
+ 45
378
+ ],
379
+ "output": 2
380
+ },
381
+ {
382
+ "input": [
383
+ [
384
+ 68,
385
+ 67,
386
+ 25,
387
+ 41,
388
+ 20,
389
+ 45,
390
+ 71,
391
+ 46,
392
+ 84,
393
+ 36,
394
+ 50,
395
+ 98,
396
+ 4,
397
+ 59,
398
+ 55,
399
+ 32,
400
+ 80,
401
+ 33,
402
+ 37,
403
+ 4,
404
+ 71,
405
+ 26,
406
+ 77,
407
+ 26,
408
+ 100,
409
+ 52,
410
+ 41,
411
+ 47,
412
+ 46,
413
+ 39,
414
+ 43,
415
+ 93,
416
+ 15,
417
+ 18,
418
+ 58,
419
+ 38,
420
+ 6
421
+ ],
422
+ 62
423
+ ],
424
+ "output": 2
425
+ },
426
+ {
427
+ "input": [
428
+ [
429
+ 33,
430
+ 2,
431
+ 53,
432
+ 21,
433
+ 56,
434
+ 19,
435
+ 58,
436
+ 56,
437
+ 72,
438
+ 63,
439
+ 92,
440
+ 40,
441
+ 96,
442
+ 10,
443
+ 44,
444
+ 49,
445
+ 73,
446
+ 51,
447
+ 59,
448
+ 15,
449
+ 27,
450
+ 95,
451
+ 98,
452
+ 82,
453
+ 10,
454
+ 8,
455
+ 33,
456
+ 32,
457
+ 79,
458
+ 25,
459
+ 41,
460
+ 66,
461
+ 68,
462
+ 82,
463
+ 61,
464
+ 76,
465
+ 57,
466
+ 48,
467
+ 81,
468
+ 7,
469
+ 20,
470
+ 25,
471
+ 72,
472
+ 79,
473
+ 7,
474
+ 51,
475
+ 68,
476
+ 28,
477
+ 80,
478
+ 61,
479
+ 5,
480
+ 53,
481
+ 29,
482
+ 31,
483
+ 30,
484
+ 94,
485
+ 9,
486
+ 47,
487
+ 40,
488
+ 88,
489
+ 19,
490
+ 33,
491
+ 56,
492
+ 98,
493
+ 58,
494
+ 46,
495
+ 6,
496
+ 93,
497
+ 69,
498
+ 55,
499
+ 7,
500
+ 85,
501
+ 75,
502
+ 14,
503
+ 45,
504
+ 79,
505
+ 27,
506
+ 76,
507
+ 31,
508
+ 81,
509
+ 98,
510
+ 89,
511
+ 3,
512
+ 20,
513
+ 48,
514
+ 65,
515
+ 67,
516
+ 43,
517
+ 20,
518
+ 71,
519
+ 55,
520
+ 21,
521
+ 80,
522
+ 32,
523
+ 5,
524
+ 82
525
+ ],
526
+ 99
527
+ ],
528
+ "output": 6
529
+ },
530
+ {
531
+ "input": [
532
+ [
533
+ 24,
534
+ 75,
535
+ 21,
536
+ 32,
537
+ 53,
538
+ 32,
539
+ 30,
540
+ 65,
541
+ 67,
542
+ 72,
543
+ 10,
544
+ 91,
545
+ 62,
546
+ 99,
547
+ 51,
548
+ 33,
549
+ 13,
550
+ 66,
551
+ 80,
552
+ 49,
553
+ 79,
554
+ 80,
555
+ 45,
556
+ 97,
557
+ 4,
558
+ 51,
559
+ 92,
560
+ 76,
561
+ 67,
562
+ 71,
563
+ 99,
564
+ 81,
565
+ 12,
566
+ 83,
567
+ 28,
568
+ 19,
569
+ 60,
570
+ 44,
571
+ 55,
572
+ 84,
573
+ 85,
574
+ 31,
575
+ 37,
576
+ 12,
577
+ 61,
578
+ 42,
579
+ 26,
580
+ 21,
581
+ 9,
582
+ 56,
583
+ 19,
584
+ 46,
585
+ 32,
586
+ 3,
587
+ 51,
588
+ 22,
589
+ 44,
590
+ 37,
591
+ 39,
592
+ 3,
593
+ 12,
594
+ 68,
595
+ 71,
596
+ 73,
597
+ 81,
598
+ 50,
599
+ 97,
600
+ 90,
601
+ 4,
602
+ 59,
603
+ 72,
604
+ 33,
605
+ 26,
606
+ 17,
607
+ 12,
608
+ 94,
609
+ 15,
610
+ 70,
611
+ 11,
612
+ 90,
613
+ 42,
614
+ 27,
615
+ 12,
616
+ 37,
617
+ 45,
618
+ 63,
619
+ 6
620
+ ],
621
+ 16
622
+ ],
623
+ "output": 1
624
+ }
625
+ ],
626
+ "haskell_template": "longestAlternatingSubarray :: [Int] -> Int -> Int\nlongestAlternatingSubarray nums threshold ",
627
+ "ocaml_template": "let longestAlternatingSubarray (nums: int list) (threshold: int) : int = ",
628
+ "scala_template": "def longestAlternatingSubarray(nums: List[Int],threshold: Int): Int = { \n \n}",
629
+ "java_template": "class Solution {\n public int longestAlternatingSubarray(int[] nums, int threshold) {\n \n }\n}",
630
+ "python_template": "class Solution(object):\n def longestAlternatingSubarray(self, nums, threshold):\n \"\"\"\n :type nums: List[int]\n :type threshold: int\n :rtype: int\n \"\"\"\n "
631
+ }
longest_even_odd_subarray_with_threshold/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 (longestAlternatingSubarray [3;2;5;4] 5)
12
+
13
+ let test2 _ = assert_equal 1 (longestAlternatingSubarray [1;2] 2)
14
+
15
+ let test3 _ = assert_equal 3 (longestAlternatingSubarray [2;3;4;5] 4)
16
+
17
+ let test4 _ = assert_equal 2 (longestAlternatingSubarray [53; 12; 16; 68; 39; 99; 81; 24; 65; 67; 59; 84; 17; 39; 42; 1; 87; 59; 34; 41] 60)
18
+
19
+ let test5 _ = assert_equal 1 (longestAlternatingSubarray [93; 15; 82; 51; 33; 7; 29; 37; 40; 29; 71; 75; 5; 63; 16; 29; 34; 16; 61; 96; 17; 76; 76; 19; 69; 70; 61; 14; 29; 10; 37] 16)
20
+
21
+ let test6 _ = assert_equal 2 (longestAlternatingSubarray [5; 89; 86; 41; 61; 81; 6; 24; 48; 36; 58; 2; 76; 25; 18; 51; 75; 1; 51; 7; 43; 9; 30; 30; 41; 41; 11; 79] 49)
22
+
23
+ let test7 _ = assert_equal 7 (longestAlternatingSubarray [76; 86; 22; 69; 47; 36; 46; 12; 56; 6; 77; 30; 77; 36; 65; 10; 32; 48; 62; 75; 58; 65; 39; 3; 9; 21; 24; 68; 93; 6; 34; 80; 84; 5; 4; 70; 5; 46; 30] 79)
24
+
25
+ let test8 _ = assert_equal 3 (longestAlternatingSubarray [7; 49; 35; 59; 41; 43; 27; 60; 13; 47; 39; 16; 56; 74; 76; 87; 17; 61; 30; 9; 99; 99; 42; 25; 18; 95; 56; 86; 41; 87; 53; 87; 32; 25; 87; 62; 58; 60; 71; 74; 16; 67; 76; 85; 78; 23; 10; 4; 96; 96; 57; 46] 45)
26
+
27
+ let test9 _ = assert_equal 2 (longestAlternatingSubarray [50; 2; 70; 95; 9; 66; 2; 82; 95; 84; 33; 65; 44; 66; 83; 17; 1; 29; 92; 8; 96; 100; 6; 74; 96; 71; 78; 73; 53; 9; 45; 79; 90; 57; 72; 49; 87; 79; 80; 67; 50; 68; 89; 15; 89; 39; 45; 51; 52; 59; 21; 12; 87; 74; 52; 30; 47; 23; 23; 56; 62; 13; 16; 51; 96; 64; 18; 12; 71; 22; 39; 95; 48; 4; 39; 42; 78; 59; 11] 39)
28
+
29
+ let test10 _ = assert_equal 2 (longestAlternatingSubarray [99; 70; 43; 46; 94; 9; 54; 6; 6; 71; 16; 38; 38; 77; 57; 96; 23; 71; 62; 12; 72; 32; 67; 64; 69; 19; 40; 58; 52; 72; 53; 3; 38; 68; 46; 17; 20; 13; 96; 75; 17; 31; 14; 31; 87; 2; 51; 1; 42; 11] 45)
30
+
31
+
32
+ (* Grouping test cases *)
33
+ let suite = "Test Suite for longestAlternatingSubarray" >::: [
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_even_odd_subarray_with_threshold/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestAlternatingSubarray(List(3,2,5,4),5), 3)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestAlternatingSubarray(List(1,2),2), 1)
10
+ }
11
+
12
+ test("test3") {
13
+ assertEquals(Main.longestAlternatingSubarray(List(2,3,4,5),4), 3)
14
+ }
15
+
16
+ test("test4") {
17
+ assertEquals(Main.longestAlternatingSubarray(List(53, 12, 16, 68, 39, 99, 81, 24, 65, 67, 59, 84, 17, 39, 42, 1, 87, 59, 34, 41),60), 2)
18
+ }
19
+
20
+ test("test5") {
21
+ assertEquals(Main.longestAlternatingSubarray(List(93, 15, 82, 51, 33, 7, 29, 37, 40, 29, 71, 75, 5, 63, 16, 29, 34, 16, 61, 96, 17, 76, 76, 19, 69, 70, 61, 14, 29, 10, 37),16), 1)
22
+ }
23
+
24
+ test("test6") {
25
+ assertEquals(Main.longestAlternatingSubarray(List(5, 89, 86, 41, 61, 81, 6, 24, 48, 36, 58, 2, 76, 25, 18, 51, 75, 1, 51, 7, 43, 9, 30, 30, 41, 41, 11, 79),49), 2)
26
+ }
27
+
28
+ test("test7") {
29
+ assertEquals(Main.longestAlternatingSubarray(List(76, 86, 22, 69, 47, 36, 46, 12, 56, 6, 77, 30, 77, 36, 65, 10, 32, 48, 62, 75, 58, 65, 39, 3, 9, 21, 24, 68, 93, 6, 34, 80, 84, 5, 4, 70, 5, 46, 30),79), 7)
30
+ }
31
+
32
+ test("test8") {
33
+ assertEquals(Main.longestAlternatingSubarray(List(7, 49, 35, 59, 41, 43, 27, 60, 13, 47, 39, 16, 56, 74, 76, 87, 17, 61, 30, 9, 99, 99, 42, 25, 18, 95, 56, 86, 41, 87, 53, 87, 32, 25, 87, 62, 58, 60, 71, 74, 16, 67, 76, 85, 78, 23, 10, 4, 96, 96, 57, 46),45), 3)
34
+ }
35
+
36
+ test("test9") {
37
+ assertEquals(Main.longestAlternatingSubarray(List(50, 2, 70, 95, 9, 66, 2, 82, 95, 84, 33, 65, 44, 66, 83, 17, 1, 29, 92, 8, 96, 100, 6, 74, 96, 71, 78, 73, 53, 9, 45, 79, 90, 57, 72, 49, 87, 79, 80, 67, 50, 68, 89, 15, 89, 39, 45, 51, 52, 59, 21, 12, 87, 74, 52, 30, 47, 23, 23, 56, 62, 13, 16, 51, 96, 64, 18, 12, 71, 22, 39, 95, 48, 4, 39, 42, 78, 59, 11),39), 2)
38
+ }
39
+
40
+ test("test10") {
41
+ assertEquals(Main.longestAlternatingSubarray(List(99, 70, 43, 46, 94, 9, 54, 6, 6, 71, 16, 38, 38, 77, 57, 96, 23, 71, 62, 12, 72, 32, 67, 64, 69, 19, 40, 58, 52, 72, 53, 3, 38, 68, 46, 17, 20, 13, 96, 75, 17, 31, 14, 31, 87, 2, 51, 1, 42, 11),45), 2)
42
+ }
43
+
44
+ }
longest_ideal_subsequence/.DS_Store ADDED
Binary file (6.15 kB). View file
 
longest_ideal_subsequence/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 (longestIdealString \"acfgbd \" 2)," 4 (longestIdealString "acfgbd" 2))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (longestIdealString \"abcd \" 3)," 4 (longestIdealString "abcd" 3))
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_ideal_subsequence/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, longestIdealString("acfgbd", 2));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, longestIdealString("abcd", 3));
19
+ }
20
+
21
+ }
longest_ideal_subsequence/meta.json ADDED
The diff for this file is too large to render. See raw diff
 
longest_ideal_subsequence/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 (longestIdealString "acfgbd" 2)
12
+
13
+ let test2 _ = assert_equal 4 (longestIdealString "abcd" 3)
14
+
15
+
16
+ (* Grouping test cases *)
17
+ let suite = "Test Suite for longestIdealString" >::: [
18
+
19
+ "test1" >:: test1;
20
+ "test2" >:: test2;
21
+ ]
22
+
23
+
24
+ (* Running the tests *)
25
+ let () = run_test_tt_main suite
26
+ end
longest_ideal_subsequence/scala_tests/MySuite.scala ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class MySuite extends munit.FunSuite {
3
+
4
+ test("test1") {
5
+ assertEquals(Main.longestIdealString("acfgbd",2), 4)
6
+ }
7
+
8
+ test("test2") {
9
+ assertEquals(Main.longestIdealString("abcd",3), 4)
10
+ }
11
+
12
+ }
longest_increasing_subsequence_ii/.DS_Store ADDED
Binary file (6.15 kB). View file
 
longest_increasing_subsequence_ii/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 (lengthOfLIS [4,2,1,4,3,4,5,8,15] 3)," 5 (lengthOfLIS [4,2,1,4,3,4,5,8,15] 3))
13
+
14
+ test2 :: Test
15
+ test2 = TestCase (assertEqual "for (lengthOfLIS [7,4,5,1,8,12,4,7] 5)," 4 (lengthOfLIS [7,4,5,1,8,12,4,7] 5))
16
+
17
+ test3 :: Test
18
+ test3 = TestCase (assertEqual "for (lengthOfLIS [1,5] 1)," 1 (lengthOfLIS [1,5] 1))
19
+
20
+
21
+ -- Grouping test cases
22
+ tests :: Test
23
+ tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
24
+
25
+ -- Running the tests
26
+ main :: IO Counts
27
+ main = runTestTT tests
longest_increasing_subsequence_ii/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(5, lengthOfLIS(new ArrayList<>(Arrays.asList(4,2,1,4,3,4,5,8,15)), 3));
15
+ }
16
+ @Test
17
+ public void test2() {
18
+ assertEquals(4, lengthOfLIS(new ArrayList<>(Arrays.asList(7,4,5,1,8,12,4,7)), 5));
19
+ }
20
+ @Test
21
+ public void test3() {
22
+ assertEquals(1, lengthOfLIS(new ArrayList<>(Arrays.asList(1,5)), 1));
23
+ }
24
+
25
+ }
longest_increasing_subsequence_ii/meta.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": 2526,
3
+ "name": "longest_increasing_subsequence_ii",
4
+ "difficulty": "Hard",
5
+ "link": "https://leetcode.com/problems/longest-increasing-subsequence-ii/",
6
+ "date": "1662249600000",
7
+ "task_description": "You are given an integer array `nums` and an integer `k`. Find the longest subsequence of `nums` that meets the following requirements: The subsequence is **strictly increasing** and The difference between adjacent elements in the subsequence is **at most** `k`. Return_ the length of the **longest** **subsequence** that meets the requirements._ A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. **Example 1:** ``` **Input:** nums = [4,2,1,4,3,4,5,8,15], k = 3 **Output:** 5 **Explanation:** The longest subsequence that meets the requirements is [1,3,4,5,8]. The subsequence has a length of 5, so we return 5. Note that the subsequence [1,3,4,5,8,15] does not meet the requirements because 15 - 8 = 7 is larger than 3. ``` **Example 2:** ``` **Input:** nums = [7,4,5,1,8,12,4,7], k = 5 **Output:** 4 **Explanation:** The longest subsequence that meets the requirements is [4,5,8,12]. The subsequence has a length of 4, so we return 4. ``` **Example 3:** ``` **Input:** nums = [1,5], k = 1 **Output:** 1 **Explanation:** The longest subsequence that meets the requirements is [1]. The subsequence has a length of 1, so we return 1. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i], k <= 105`",
8
+ "public_test_cases": [
9
+ {
10
+ "label": "Example 1",
11
+ "input": "nums = [4,2,1,4,3,4,5,8,15], k = 3",
12
+ "output": "5 "
13
+ },
14
+ {
15
+ "label": "Example 2",
16
+ "input": "nums = [7,4,5,1,8,12,4,7], k = 5",
17
+ "output": "4 "
18
+ },
19
+ {
20
+ "label": "Example 3",
21
+ "input": "nums = [1,5], k = 1",
22
+ "output": "1 "
23
+ }
24
+ ],
25
+ "private_test_cases": [
26
+ {
27
+ "input": [
28
+ [
29
+ 9,
30
+ 12,
31
+ 13,
32
+ 16,
33
+ 17,
34
+ 28,
35
+ 29,
36
+ 30,
37
+ 34,
38
+ 40,
39
+ 44,
40
+ 45,
41
+ 57,
42
+ 65
43
+ ],
44
+ 97
45
+ ],
46
+ "output": 14
47
+ },
48
+ {
49
+ "input": [
50
+ [
51
+ 2,
52
+ 4,
53
+ 16,
54
+ 27,
55
+ 40,
56
+ 43,
57
+ 48,
58
+ 55,
59
+ 60,
60
+ 82,
61
+ 87,
62
+ 91,
63
+ 98,
64
+ 99
65
+ ],
66
+ 75
67
+ ],
68
+ "output": 14
69
+ },
70
+ {
71
+ "input": [
72
+ [
73
+ 20,
74
+ 27,
75
+ 42,
76
+ 51,
77
+ 52,
78
+ 57,
79
+ 64,
80
+ 66,
81
+ 76,
82
+ 77,
83
+ 81,
84
+ 89,
85
+ 95,
86
+ 100
87
+ ],
88
+ 45
89
+ ],
90
+ "output": 14
91
+ },
92
+ {
93
+ "input": [
94
+ [
95
+ 14,
96
+ 28,
97
+ 81
98
+ ],
99
+ 96
100
+ ],
101
+ "output": 3
102
+ },
103
+ {
104
+ "input": [
105
+ [
106
+ 3,
107
+ 19,
108
+ 28,
109
+ 30,
110
+ 32,
111
+ 47,
112
+ 63,
113
+ 64,
114
+ 69,
115
+ 80,
116
+ 94,
117
+ 95
118
+ ],
119
+ 33
120
+ ],
121
+ "output": 12
122
+ },
123
+ {
124
+ "input": [
125
+ [
126
+ 4,
127
+ 5,
128
+ 18,
129
+ 26,
130
+ 33,
131
+ 41,
132
+ 42,
133
+ 62,
134
+ 69,
135
+ 73,
136
+ 75,
137
+ 76,
138
+ 78,
139
+ 80,
140
+ 87,
141
+ 96,
142
+ 97,
143
+ 98,
144
+ 99
145
+ ],
146
+ 39
147
+ ],
148
+ "output": 19
149
+ },
150
+ {
151
+ "input": [
152
+ [
153
+ 65,
154
+ 94
155
+ ],
156
+ 18
157
+ ],
158
+ "output": 1
159
+ },
160
+ {
161
+ "input": [
162
+ [
163
+ 64,
164
+ 95
165
+ ],
166
+ 92
167
+ ],
168
+ "output": 2
169
+ },
170
+ {
171
+ "input": [
172
+ [
173
+ 8,
174
+ 15,
175
+ 16,
176
+ 21,
177
+ 27,
178
+ 29,
179
+ 47,
180
+ 59,
181
+ 67,
182
+ 68,
183
+ 93,
184
+ 98
185
+ ],
186
+ 5
187
+ ],
188
+ "output": 3
189
+ },
190
+ {
191
+ "input": [
192
+ [
193
+ 9,
194
+ 32,
195
+ 35,
196
+ 49,
197
+ 53,
198
+ 65,
199
+ 69,
200
+ 79,
201
+ 83,
202
+ 87,
203
+ 89
204
+ ],
205
+ 86
206
+ ],
207
+ "output": 11
208
+ }
209
+ ],
210
+ "haskell_template": "lengthOfLIS :: [Int] -> Int -> Int\nlengthOfLIS nums k ",
211
+ "ocaml_template": "let lengthOfLIS (nums: int list) (k: int) : int = ",
212
+ "scala_template": "def lengthOfLIS(nums: List[Int],k: Int): Int = { \n \n}",
213
+ "java_template": "public static int lengthOfLIS(List<Integer> nums, int k) {\n\n}",
214
+ "python_template": "class Solution(object):\n def lengthOfLIS(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "
215
+ }