75b226d491c5cfd0cb0576f9fbda1a33b06cbc80a09ef580568008fe60ff15ba
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +4 -0
- first_letter_to_appear_twice/java_tests/Main.java +21 -0
- first_letter_to_appear_twice/meta.json +67 -0
- first_letter_to_appear_twice/ocaml_tests/main.ml +26 -0
- first_letter_to_appear_twice/scala_tests/MySuite.scala +12 -0
- frequencies_of_shortest_supersequences/haskell_tests/Main.hs +44 -0
- frequencies_of_shortest_supersequences/java_tests/Main.java +24 -0
- frequencies_of_shortest_supersequences/meta.json +720 -0
- frequencies_of_shortest_supersequences/ocaml_tests/main.ml +45 -0
- frequencies_of_shortest_supersequences/scala_tests/MySuite.scala +36 -0
- frog_jump_ii/.DS_Store +0 -0
- frog_jump_ii/haskell_tests/Main.hs +24 -0
- frog_jump_ii/java_tests/Main.java +21 -0
- frog_jump_ii/meta.json +3 -0
- frog_jump_ii/ocaml_tests/main.ml +26 -0
- frog_jump_ii/scala_tests/MySuite.scala +12 -0
- fruits_into_baskets_ii/haskell_tests/Main.hs +45 -0
- fruits_into_baskets_ii/java_tests/Main.java +21 -0
- fruits_into_baskets_ii/meta.json +1047 -0
- fruits_into_baskets_ii/ocaml_tests/main.ml +50 -0
- fruits_into_baskets_ii/scala_tests/MySuite.scala +44 -0
- fruits_into_baskets_iii/haskell_tests/Main.hs +3 -0
- fruits_into_baskets_iii/java_tests/Main.java +21 -0
- fruits_into_baskets_iii/meta.json +3 -0
- fruits_into_baskets_iii/ocaml_tests/main.ml +0 -0
- fruits_into_baskets_iii/scala_tests/MySuite.scala +0 -0
- furthest_point_from_origin/haskell_tests/Main.hs +44 -0
- furthest_point_from_origin/java_tests/Main.java +24 -0
- furthest_point_from_origin/meta.json +52 -0
- furthest_point_from_origin/ocaml_tests/main.ml +45 -0
- furthest_point_from_origin/scala_tests/MySuite.scala +36 -0
- greatest_common_divisor_traversal/haskell_tests/Main.hs +0 -0
- greatest_common_divisor_traversal/java_tests/Main.java +24 -0
- greatest_common_divisor_traversal/meta.json +0 -0
- greatest_common_divisor_traversal/ocaml_tests/main.ml +0 -0
- greatest_common_divisor_traversal/scala_tests/MySuite.scala +0 -0
- groups_of_strings/.DS_Store +0 -0
- groups_of_strings/haskell_tests/Main.hs +24 -0
- groups_of_strings/java_tests/Main.java +21 -0
- groups_of_strings/meta.json +26 -0
- groups_of_strings/ocaml_tests/main.ml +26 -0
- groups_of_strings/scala_tests/MySuite.scala +12 -0
- handling_sum_queries_after_update/.DS_Store +0 -0
- handling_sum_queries_after_update/haskell_tests/Main.hs +24 -0
- handling_sum_queries_after_update/java_tests/Main.java +21 -0
- handling_sum_queries_after_update/meta.json +3 -0
- handling_sum_queries_after_update/ocaml_tests/main.ml +26 -0
- handling_sum_queries_after_update/scala_tests/MySuite.scala +12 -0
- happy_students/haskell_tests/Main.hs +0 -0
- happy_students/java_tests/Main.java +20 -0
.gitattributes
CHANGED
|
@@ -131,3 +131,7 @@ find_the_original_array_of_prefix_xor/meta.json filter=lfs diff=lfs merge=lfs -t
|
|
| 131 |
find_the_score_of_all_prefixes_of_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 132 |
find_x_sum_of_all_k_long_subarrays_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 133 |
find_x_sum_of_all_k_long_subarrays_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
find_the_score_of_all_prefixes_of_an_array/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 132 |
find_x_sum_of_all_k_long_subarrays_ii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 133 |
find_x_sum_of_all_k_long_subarrays_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 134 |
+
frog_jump_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 135 |
+
fruits_into_baskets_iii/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 136 |
+
fruits_into_baskets_iii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 137 |
+
handling_sum_queries_after_update/meta.json filter=lfs diff=lfs merge=lfs -text
|
first_letter_to_appear_twice/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("abccbaacz", repeatedCharacter("abccbaacz"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals("abcdd", repeatedCharacter("abcdd"));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
first_letter_to_appear_twice/meta.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2427,
|
| 3 |
+
"name": "first_letter_to_appear_twice",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/first-letter-to-appear-twice/",
|
| 6 |
+
"date": "1658016000000",
|
| 7 |
+
"task_description": "Given a string `s` consisting of lowercase English letters, return _the first letter to appear **twice**_. **Note**: A letter `a` appears twice before another letter `b` if the **second** occurrence of `a` is before the **second** occurrence of `b`. `s` will contain at least one letter that appears twice. **Example 1:** ``` **Input:** s = \"abccbaacz\" **Output:** \"c\" **Explanation:** The letter 'a' appears on the indexes 0, 5 and 6. The letter 'b' appears on the indexes 1 and 4. The letter 'c' appears on the indexes 2, 3 and 7. The letter 'z' appears on the index 8. The letter 'c' is the first letter to appear twice, because out of all the letters the index of its second occurrence is the smallest. ``` **Example 2:** ``` **Input:** s = \"abcdd\" **Output:** \"d\" **Explanation:** The only letter that appears twice is 'd' so we return 'd'. ``` **Constraints:** `2 <= s.length <= 100` `s` consists of lowercase English letters. `s` has at least one repeated letter.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "s = \"abccbaacz\"",
|
| 12 |
+
"output": "\"c\" "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "s = \"abcdd\"",
|
| 17 |
+
"output": "\"d\" "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": "lihgpxiwragmffsbmwljpdzewhayrwglxuoascblhfwmcfxbqmmscjalanzce",
|
| 23 |
+
"output": "i"
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"input": "hejeouzseeyttwsqdum",
|
| 27 |
+
"output": "e"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"input": "nbdcpvhaxaxbptwzsiwidxzpjifbmvsmxkcazfxmzdrvsxkhcdwufiqgnwceqwzxthkhkxkiqpxhguze",
|
| 31 |
+
"output": "a"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"input": "udcioltwduvlxyrehbtsppaplnumkogypzyjwoizzidldeodaicwugncujqawosowyprgdcq",
|
| 35 |
+
"output": "d"
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"input": "qnzubkqcxxharvgrfmzexxzhjeiukxhvrxt",
|
| 39 |
+
"output": "q"
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"input": "nxmzidnksvmdupiatuukdmctawuwpciuqdgaklxytdbkltuuruehmlnwhwzwpedzevxsokbtzegfqvepjqcoylupy",
|
| 43 |
+
"output": "n"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"input": "mnzfavtseliskygvvvjhfaeceefitjquvpupq",
|
| 47 |
+
"output": "s"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"input": "awuyabsbpkn",
|
| 51 |
+
"output": "a"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"input": "cgmmqlzwaelpxgfuodrgoazyhagvonitksncrxmprojdiihtjojepwyebmwijbykingjfyrhjreboeoks",
|
| 55 |
+
"output": "m"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"input": "jeliziinaufbiufbhlsflmiqbqobiphyvzgheiqufmwj",
|
| 59 |
+
"output": "i"
|
| 60 |
+
}
|
| 61 |
+
],
|
| 62 |
+
"haskell_template": "repeatedCharacter :: String -> String\nrepeatedCharacter s ",
|
| 63 |
+
"ocaml_template": "let repeatedCharacter (s: string) : string = ",
|
| 64 |
+
"scala_template": "def repeatedCharacter(s: String): String = { \n \n}",
|
| 65 |
+
"java_template": "public static String repeatedCharacter(String s) {\n\n}",
|
| 66 |
+
"python_template": "class Solution(object):\n def repeatedCharacter(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n "
|
| 67 |
+
}
|
first_letter_to_appear_twice/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 "c" (repeatedCharacter "abccbaacz")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal "d" (repeatedCharacter "abcdd")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for repeatedCharacter" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
first_letter_to_appear_twice/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.repeatedCharacter("abccbaacz"), "c")
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.repeatedCharacter("abcdd"), "d")
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
frequencies_of_shortest_supersequences/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
supersequences :: [String] -> [[Int]]
|
| 7 |
+
supersequences words = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (supersequences [ \"ab \", \"ba \"])," [[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] (supersequences ["ab","ba"]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (supersequences [ \"aa \", \"ac \"])," [[2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] (supersequences ["aa","ac"]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (supersequences [ \"aa \", \"bb \", \"cc \"])," [[2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] (supersequences ["aa","bb","cc"]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (supersequences [ \"wp \", \"gb \", \"mv \", \"ng \", \"em \", \"ls \", \"ay \", \"ah \", \"xt \", \"ua \", \"pn \", \"mg \", \"fs \", \"pq \", \"kp \", \"ja \", \"hs \", \"au \", \"wh \", \"tc \", \"cm \", \"ku \", \"zb \", \"cz \", \"sm \", \"bk \", \"nu \", \"wu \", \"su \", \"yh \", \"rv \", \"oz \", \"ce \", \"br \", \"fy \", \"jq \", \"qg \", \"qr \", \"zz \", \"xi \", \"ov \", \"ib \", \"ci \", \"cq \", \"gm \", \"vt \", \"gq \", \"lx \", \"hz \", \"qw \", \"pp \", \"oo \", \"xv \", \"ey \", \"gc \", \"sa \", \"fw \", \"dx \", \"zv \", \"ni \", \"gr \", \"kd \", \"wg \", \"yy \", \"gl \", \"wy \", \"sn \", \"bn \", \"kn \", \"qp \", \"vg \", \"rb \", \"hh \", \"nz \", \"jx \", \"mu \", \"xu \", \"mn \", \"hy \", \"mr \", \"ev \", \"qa \", \"me \", \"sq \", \"dg \", \"qu \", \"iy \", \"od \", \"sf \", \"jf \", \"tt \", \"ym \", \"ki \", \"wi \", \"ts \", \"ur \", \"du \", \"dd \", \"dq \", \"ie \", \"zg \", \"wc \", \"bj \", \"xf \", \"md \", \"ac \", \"sx \", \"ra \", \"my \", \"rd \", \"fq \", \"vy \", \"bi \", \"fn \", \"ew \", \"rf \", \"fu \", \"za \", \"rr \", \"py \", \"iz \", \"kk \", \"pw \", \"rt \", \"ff \", \"tw \", \"fe \", \"lj \", \"bd \", \"fz \", \"re \", \"mb \", \"th \", \"et \", \"zl \", \"uz \", \"qh \", \"be \", \"kx \", \"dj \", \"jm \", \"ga \", \"zn \", \"bh \", \"vq \", \"wn \", \"qn \", \"np \", \"cb \", \"wl \", \"ll \", \"st \", \"vl \", \"vd \", \"tq \", \"no \", \"lp \", \"ho \", \"nt \", \"wv \", \"lz \", \"ys \", \"qe \", \"vh \", \"ge \", \"dm \", \"mz \", \"uo \", \"lt \", \"hv \", \"kh \", \"jr \", \"db \", \"nh \", \"pg \", \"qv \", \"qf \", \"vp \", \"va \", \"xm \", \"ry \", \"to \", \"li \", \"sk \", \"lq \", \"bt \", \"al \", \"we \", \"fb \", \"ea \", \"wd \", \"up \", \"az \", \"vn \", \"hc \", \"ui \", \"tp \", \"ql \", \"hg \", \"lk \", \"tm \", \"pi \", \"zs \", \"aj \", \"tl \", \"td \", \"kq \", \"sr \", \"so \", \"ou \", \"gi \", \"tn \", \"ha \", \"yp \", \"rs \", \"dp \", \"pl \", \"ub \", \"ot \", \"na \", \"oj \", \"nn \", \"lm \", \"xd \", \"cv \", \"en \", \"pd \"])," [[2,2,1,2,2,2,2,2,1,1,2,2,1,2,2,2,2,2,1,2,1,1,1,1,2,2]] (supersequences ["wp", "gb", "mv", "ng", "em", "ls", "ay", "ah", "xt", "ua", "pn", "mg", "fs", "pq", "kp", "ja", "hs", "au", "wh", "tc", "cm", "ku", "zb", "cz", "sm", "bk", "nu", "wu", "su", "yh", "rv", "oz", "ce", "br", "fy", "jq", "qg", "qr", "zz", "xi", "ov", "ib", "ci", "cq", "gm", "vt", "gq", "lx", "hz", "qw", "pp", "oo", "xv", "ey", "gc", "sa", "fw", "dx", "zv", "ni", "gr", "kd", "wg", "yy", "gl", "wy", "sn", "bn", "kn", "qp", "vg", "rb", "hh", "nz", "jx", "mu", "xu", "mn", "hy", "mr", "ev", "qa", "me", "sq", "dg", "qu", "iy", "od", "sf", "jf", "tt", "ym", "ki", "wi", "ts", "ur", "du", "dd", "dq", "ie", "zg", "wc", "bj", "xf", "md", "ac", "sx", "ra", "my", "rd", "fq", "vy", "bi", "fn", "ew", "rf", "fu", "za", "rr", "py", "iz", "kk", "pw", "rt", "ff", "tw", "fe", "lj", "bd", "fz", "re", "mb", "th", "et", "zl", "uz", "qh", "be", "kx", "dj", "jm", "ga", "zn", "bh", "vq", "wn", "qn", "np", "cb", "wl", "ll", "st", "vl", "vd", "tq", "no", "lp", "ho", "nt", "wv", "lz", "ys", "qe", "vh", "ge", "dm", "mz", "uo", "lt", "hv", "kh", "jr", "db", "nh", "pg", "qv", "qf", "vp", "va", "xm", "ry", "to", "li", "sk", "lq", "bt", "al", "we", "fb", "ea", "wd", "up", "az", "vn", "hc", "ui", "tp", "ql", "hg", "lk", "tm", "pi", "zs", "aj", "tl", "td", "kq", "sr", "so", "ou", "gi", "tn", "ha", "yp", "rs", "dp", "pl", "ub", "ot", "na", "oj", "nn", "lm", "xd", "cv", "en", "pd"]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (supersequences [ \"kj \", \"kn \", \"eb \", \"vo \", \"hg \", \"jn \", \"qd \", \"ye \", \"ai \", \"ux \", \"cg \", \"lh \", \"qg \", \"ls \", \"lf \", \"wd \", \"pf \"])," [[1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,1,0]] (supersequences ["kj", "kn", "eb", "vo", "hg", "jn", "qd", "ye", "ai", "ux", "cg", "lh", "qg", "ls", "lf", "wd", "pf"]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (supersequences [ \"jv \", \"vx \", \"jo \", \"wf \", \"uo \", \"gb \", \"zt \", \"db \", \"ko \", \"hu \", \"bc \", \"pq \", \"eb \", \"sj \", \"se \", \"bt \", \"wa \", \"mw \", \"xo \", \"qx \", \"da \", \"wz \", \"ok \", \"ts \", \"dh \", \"sb \", \"du \", \"yp \", \"dp \", \"ub \", \"gs \", \"bm \"])," [[1,2,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,1,2,1,1,1,1,1,1],[1,2,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,1,2,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,2,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,2,1,1,1,1,1,1,1]] (supersequences ["jv", "vx", "jo", "wf", "uo", "gb", "zt", "db", "ko", "hu", "bc", "pq", "eb", "sj", "se", "bt", "wa", "mw", "xo", "qx", "da", "wz", "ok", "ts", "dh", "sb", "du", "yp", "dp", "ub", "gs", "bm"]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (supersequences [ \"sk \", \"fj \", \"km \", \"ql \", \"in \", \"ex \", \"zp \", \"px \", \"dn \", \"ej \", \"xg \", \"pp \", \"yx \", \"ay \", \"jz \"])," [[1,0,0,1,1,1,1,0,1,1,1,1,1,1,0,2,1,0,1,0,0,0,0,1,1,1]] (supersequences ["sk", "fj", "km", "ql", "in", "ex", "zp", "px", "dn", "ej", "xg", "pp", "yx", "ay", "jz"]))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (supersequences [ \"ex \", \"ao \", \"ak \", \"dy \", \"gr \", \"rf \", \"mz \", \"rr \", \"ch \", \"iz \", \"ry \", \"xw \", \"ju \", \"pj \", \"rt \", \"di \", \"eg \", \"ox \", \"ja \", \"ct \", \"je \", \"fp \", \"ku \", \"ph \", \"nb \", \"gh \", \"az \", \"fg \", \"tg \", \"kc \", \"qa \", \"gn \", \"oq \", \"qs \", \"gg \", \"ej \", \"ce \", \"xl \", \"un \", \"av \", \"cf \", \"bq \", \"uj \", \"jq \", \"xj \", \"oa \", \"km \", \"zz \", \"uu \", \"hn \", \"wj \", \"bo \", \"df \", \"co \", \"zi \", \"cv \", \"dm \", \"rn \", \"an \"])," [[2,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2],[2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2]] (supersequences ["ex", "ao", "ak", "dy", "gr", "rf", "mz", "rr", "ch", "iz", "ry", "xw", "ju", "pj", "rt", "di", "eg", "ox", "ja", "ct", "je", "fp", "ku", "ph", "nb", "gh", "az", "fg", "tg", "kc", "qa", "gn", "oq", "qs", "gg", "ej", "ce", "xl", "un", "av", "cf", "bq", "uj", "jq", "xj", "oa", "km", "zz", "uu", "hn", "wj", "bo", "df", "co", "zi", "cv", "dm", "rn", "an"]))
|
| 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
|
frequencies_of_shortest_supersequences/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(Arrays.asList(Arrays.asList(1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),Arrays.asList(2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)), supersequences(Arrays.asList("ab","ba")));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(Arrays.asList(Arrays.asList(2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)), supersequences(Arrays.asList("aa","ac")));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(Arrays.asList(Arrays.asList(2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)), supersequences(Arrays.asList("aa","bb","cc")));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
frequencies_of_shortest_supersequences/meta.json
ADDED
|
@@ -0,0 +1,720 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3713,
|
| 3 |
+
"name": "frequencies_of_shortest_supersequences",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/frequencies-of-shortest-supersequences/",
|
| 6 |
+
"date": "2025-01-19 00:00:00",
|
| 7 |
+
"task_description": "You are given an array of strings `words`. Find all **shortest common supersequences (SCS)** of `words` that are not permutations of each other. A **shortest common supersequence** is a string of **minimum** length that contains each string in `words` as a subsequence. Return a 2D array of integers `freqs` that represent all the SCSs. Each `freqs[i]` is an array of size 26, representing the frequency of each letter in the lowercase English alphabet for a single SCS. You may return the frequency arrays in any order. **Example 1:** **Input:** words = [\"ab\",\"ba\"] **Output: **[[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] **Explanation:** The two SCSs are `\"aba\"` and `\"bab\"`. The output is the letter frequencies for each one. **Example 2:** **Input:** words = [\"aa\",\"ac\"] **Output: **[[2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] **Explanation:** The two SCSs are `\"aac\"` and `\"aca\"`. Since they are permutations of each other, keep only `\"aac\"`. **Example 3:** **Input:** words = [\"aa\",\"bb\",\"cc\"] **Output: **[[2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] **Explanation:** `\"aabbcc\"` and all its permutations are SCSs. **Constraints:** `1 <= words.length <= 256` `words[i].length == 2` All strings in `words` will altogether be composed of no more than 16 unique lowercase letters. All strings in `words` are unique.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "words = [\"ab\",\"ba\"]",
|
| 12 |
+
"output": "[[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "words = [\"aa\",\"ac\"]",
|
| 17 |
+
"output": "[[2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "words = [\"aa\",\"bb\",\"cc\"]",
|
| 22 |
+
"output": "[[2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]] "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
"\"wp\"",
|
| 29 |
+
"\"gb\"",
|
| 30 |
+
"\"mv\"",
|
| 31 |
+
"\"ng\"",
|
| 32 |
+
"\"em\"",
|
| 33 |
+
"\"ls\"",
|
| 34 |
+
"\"ay\"",
|
| 35 |
+
"\"ah\"",
|
| 36 |
+
"\"xt\"",
|
| 37 |
+
"\"ua\"",
|
| 38 |
+
"\"pn\"",
|
| 39 |
+
"\"mg\"",
|
| 40 |
+
"\"fs\"",
|
| 41 |
+
"\"pq\"",
|
| 42 |
+
"\"kp\"",
|
| 43 |
+
"\"ja\"",
|
| 44 |
+
"\"hs\"",
|
| 45 |
+
"\"au\"",
|
| 46 |
+
"\"wh\"",
|
| 47 |
+
"\"tc\"",
|
| 48 |
+
"\"cm\"",
|
| 49 |
+
"\"ku\"",
|
| 50 |
+
"\"zb\"",
|
| 51 |
+
"\"cz\"",
|
| 52 |
+
"\"sm\"",
|
| 53 |
+
"\"bk\"",
|
| 54 |
+
"\"nu\"",
|
| 55 |
+
"\"wu\"",
|
| 56 |
+
"\"su\"",
|
| 57 |
+
"\"yh\"",
|
| 58 |
+
"\"rv\"",
|
| 59 |
+
"\"oz\"",
|
| 60 |
+
"\"ce\"",
|
| 61 |
+
"\"br\"",
|
| 62 |
+
"\"fy\"",
|
| 63 |
+
"\"jq\"",
|
| 64 |
+
"\"qg\"",
|
| 65 |
+
"\"qr\"",
|
| 66 |
+
"\"zz\"",
|
| 67 |
+
"\"xi\"",
|
| 68 |
+
"\"ov\"",
|
| 69 |
+
"\"ib\"",
|
| 70 |
+
"\"ci\"",
|
| 71 |
+
"\"cq\"",
|
| 72 |
+
"\"gm\"",
|
| 73 |
+
"\"vt\"",
|
| 74 |
+
"\"gq\"",
|
| 75 |
+
"\"lx\"",
|
| 76 |
+
"\"hz\"",
|
| 77 |
+
"\"qw\"",
|
| 78 |
+
"\"pp\"",
|
| 79 |
+
"\"oo\"",
|
| 80 |
+
"\"xv\"",
|
| 81 |
+
"\"ey\"",
|
| 82 |
+
"\"gc\"",
|
| 83 |
+
"\"sa\"",
|
| 84 |
+
"\"fw\"",
|
| 85 |
+
"\"dx\"",
|
| 86 |
+
"\"zv\"",
|
| 87 |
+
"\"ni\"",
|
| 88 |
+
"\"gr\"",
|
| 89 |
+
"\"kd\"",
|
| 90 |
+
"\"wg\"",
|
| 91 |
+
"\"yy\"",
|
| 92 |
+
"\"gl\"",
|
| 93 |
+
"\"wy\"",
|
| 94 |
+
"\"sn\"",
|
| 95 |
+
"\"bn\"",
|
| 96 |
+
"\"kn\"",
|
| 97 |
+
"\"qp\"",
|
| 98 |
+
"\"vg\"",
|
| 99 |
+
"\"rb\"",
|
| 100 |
+
"\"hh\"",
|
| 101 |
+
"\"nz\"",
|
| 102 |
+
"\"jx\"",
|
| 103 |
+
"\"mu\"",
|
| 104 |
+
"\"xu\"",
|
| 105 |
+
"\"mn\"",
|
| 106 |
+
"\"hy\"",
|
| 107 |
+
"\"mr\"",
|
| 108 |
+
"\"ev\"",
|
| 109 |
+
"\"qa\"",
|
| 110 |
+
"\"me\"",
|
| 111 |
+
"\"sq\"",
|
| 112 |
+
"\"dg\"",
|
| 113 |
+
"\"qu\"",
|
| 114 |
+
"\"iy\"",
|
| 115 |
+
"\"od\"",
|
| 116 |
+
"\"sf\"",
|
| 117 |
+
"\"jf\"",
|
| 118 |
+
"\"tt\"",
|
| 119 |
+
"\"ym\"",
|
| 120 |
+
"\"ki\"",
|
| 121 |
+
"\"wi\"",
|
| 122 |
+
"\"ts\"",
|
| 123 |
+
"\"ur\"",
|
| 124 |
+
"\"du\"",
|
| 125 |
+
"\"dd\"",
|
| 126 |
+
"\"dq\"",
|
| 127 |
+
"\"ie\"",
|
| 128 |
+
"\"zg\"",
|
| 129 |
+
"\"wc\"",
|
| 130 |
+
"\"bj\"",
|
| 131 |
+
"\"xf\"",
|
| 132 |
+
"\"md\"",
|
| 133 |
+
"\"ac\"",
|
| 134 |
+
"\"sx\"",
|
| 135 |
+
"\"ra\"",
|
| 136 |
+
"\"my\"",
|
| 137 |
+
"\"rd\"",
|
| 138 |
+
"\"fq\"",
|
| 139 |
+
"\"vy\"",
|
| 140 |
+
"\"bi\"",
|
| 141 |
+
"\"fn\"",
|
| 142 |
+
"\"ew\"",
|
| 143 |
+
"\"rf\"",
|
| 144 |
+
"\"fu\"",
|
| 145 |
+
"\"za\"",
|
| 146 |
+
"\"rr\"",
|
| 147 |
+
"\"py\"",
|
| 148 |
+
"\"iz\"",
|
| 149 |
+
"\"kk\"",
|
| 150 |
+
"\"pw\"",
|
| 151 |
+
"\"rt\"",
|
| 152 |
+
"\"ff\"",
|
| 153 |
+
"\"tw\"",
|
| 154 |
+
"\"fe\"",
|
| 155 |
+
"\"lj\"",
|
| 156 |
+
"\"bd\"",
|
| 157 |
+
"\"fz\"",
|
| 158 |
+
"\"re\"",
|
| 159 |
+
"\"mb\"",
|
| 160 |
+
"\"th\"",
|
| 161 |
+
"\"et\"",
|
| 162 |
+
"\"zl\"",
|
| 163 |
+
"\"uz\"",
|
| 164 |
+
"\"qh\"",
|
| 165 |
+
"\"be\"",
|
| 166 |
+
"\"kx\"",
|
| 167 |
+
"\"dj\"",
|
| 168 |
+
"\"jm\"",
|
| 169 |
+
"\"ga\"",
|
| 170 |
+
"\"zn\"",
|
| 171 |
+
"\"bh\"",
|
| 172 |
+
"\"vq\"",
|
| 173 |
+
"\"wn\"",
|
| 174 |
+
"\"qn\"",
|
| 175 |
+
"\"np\"",
|
| 176 |
+
"\"cb\"",
|
| 177 |
+
"\"wl\"",
|
| 178 |
+
"\"ll\"",
|
| 179 |
+
"\"st\"",
|
| 180 |
+
"\"vl\"",
|
| 181 |
+
"\"vd\"",
|
| 182 |
+
"\"tq\"",
|
| 183 |
+
"\"no\"",
|
| 184 |
+
"\"lp\"",
|
| 185 |
+
"\"ho\"",
|
| 186 |
+
"\"nt\"",
|
| 187 |
+
"\"wv\"",
|
| 188 |
+
"\"lz\"",
|
| 189 |
+
"\"ys\"",
|
| 190 |
+
"\"qe\"",
|
| 191 |
+
"\"vh\"",
|
| 192 |
+
"\"ge\"",
|
| 193 |
+
"\"dm\"",
|
| 194 |
+
"\"mz\"",
|
| 195 |
+
"\"uo\"",
|
| 196 |
+
"\"lt\"",
|
| 197 |
+
"\"hv\"",
|
| 198 |
+
"\"kh\"",
|
| 199 |
+
"\"jr\"",
|
| 200 |
+
"\"db\"",
|
| 201 |
+
"\"nh\"",
|
| 202 |
+
"\"pg\"",
|
| 203 |
+
"\"qv\"",
|
| 204 |
+
"\"qf\"",
|
| 205 |
+
"\"vp\"",
|
| 206 |
+
"\"va\"",
|
| 207 |
+
"\"xm\"",
|
| 208 |
+
"\"ry\"",
|
| 209 |
+
"\"to\"",
|
| 210 |
+
"\"li\"",
|
| 211 |
+
"\"sk\"",
|
| 212 |
+
"\"lq\"",
|
| 213 |
+
"\"bt\"",
|
| 214 |
+
"\"al\"",
|
| 215 |
+
"\"we\"",
|
| 216 |
+
"\"fb\"",
|
| 217 |
+
"\"ea\"",
|
| 218 |
+
"\"wd\"",
|
| 219 |
+
"\"up\"",
|
| 220 |
+
"\"az\"",
|
| 221 |
+
"\"vn\"",
|
| 222 |
+
"\"hc\"",
|
| 223 |
+
"\"ui\"",
|
| 224 |
+
"\"tp\"",
|
| 225 |
+
"\"ql\"",
|
| 226 |
+
"\"hg\"",
|
| 227 |
+
"\"lk\"",
|
| 228 |
+
"\"tm\"",
|
| 229 |
+
"\"pi\"",
|
| 230 |
+
"\"zs\"",
|
| 231 |
+
"\"aj\"",
|
| 232 |
+
"\"tl\"",
|
| 233 |
+
"\"td\"",
|
| 234 |
+
"\"kq\"",
|
| 235 |
+
"\"sr\"",
|
| 236 |
+
"\"so\"",
|
| 237 |
+
"\"ou\"",
|
| 238 |
+
"\"gi\"",
|
| 239 |
+
"\"tn\"",
|
| 240 |
+
"\"ha\"",
|
| 241 |
+
"\"yp\"",
|
| 242 |
+
"\"rs\"",
|
| 243 |
+
"\"dp\"",
|
| 244 |
+
"\"pl\"",
|
| 245 |
+
"\"ub\"",
|
| 246 |
+
"\"ot\"",
|
| 247 |
+
"\"na\"",
|
| 248 |
+
"\"oj\"",
|
| 249 |
+
"\"nn\"",
|
| 250 |
+
"\"lm\"",
|
| 251 |
+
"\"xd\"",
|
| 252 |
+
"\"cv\"",
|
| 253 |
+
"\"en\"",
|
| 254 |
+
"\"pd\""
|
| 255 |
+
],
|
| 256 |
+
"output": [
|
| 257 |
+
[
|
| 258 |
+
2,
|
| 259 |
+
2,
|
| 260 |
+
1,
|
| 261 |
+
2,
|
| 262 |
+
2,
|
| 263 |
+
2,
|
| 264 |
+
2,
|
| 265 |
+
2,
|
| 266 |
+
1,
|
| 267 |
+
1,
|
| 268 |
+
2,
|
| 269 |
+
2,
|
| 270 |
+
1,
|
| 271 |
+
2,
|
| 272 |
+
2,
|
| 273 |
+
2,
|
| 274 |
+
2,
|
| 275 |
+
2,
|
| 276 |
+
1,
|
| 277 |
+
2,
|
| 278 |
+
1,
|
| 279 |
+
1,
|
| 280 |
+
1,
|
| 281 |
+
1,
|
| 282 |
+
2,
|
| 283 |
+
2
|
| 284 |
+
]
|
| 285 |
+
]
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
"input": [
|
| 289 |
+
"\"kj\"",
|
| 290 |
+
"\"kn\"",
|
| 291 |
+
"\"eb\"",
|
| 292 |
+
"\"vo\"",
|
| 293 |
+
"\"hg\"",
|
| 294 |
+
"\"jn\"",
|
| 295 |
+
"\"qd\"",
|
| 296 |
+
"\"ye\"",
|
| 297 |
+
"\"ai\"",
|
| 298 |
+
"\"ux\"",
|
| 299 |
+
"\"cg\"",
|
| 300 |
+
"\"lh\"",
|
| 301 |
+
"\"qg\"",
|
| 302 |
+
"\"ls\"",
|
| 303 |
+
"\"lf\"",
|
| 304 |
+
"\"wd\"",
|
| 305 |
+
"\"pf\""
|
| 306 |
+
],
|
| 307 |
+
"output": [
|
| 308 |
+
[
|
| 309 |
+
1,
|
| 310 |
+
1,
|
| 311 |
+
1,
|
| 312 |
+
1,
|
| 313 |
+
1,
|
| 314 |
+
1,
|
| 315 |
+
1,
|
| 316 |
+
1,
|
| 317 |
+
1,
|
| 318 |
+
1,
|
| 319 |
+
1,
|
| 320 |
+
1,
|
| 321 |
+
0,
|
| 322 |
+
1,
|
| 323 |
+
1,
|
| 324 |
+
1,
|
| 325 |
+
1,
|
| 326 |
+
0,
|
| 327 |
+
1,
|
| 328 |
+
0,
|
| 329 |
+
1,
|
| 330 |
+
1,
|
| 331 |
+
1,
|
| 332 |
+
1,
|
| 333 |
+
1,
|
| 334 |
+
0
|
| 335 |
+
]
|
| 336 |
+
]
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"input": [
|
| 340 |
+
"\"jv\"",
|
| 341 |
+
"\"vx\"",
|
| 342 |
+
"\"jo\"",
|
| 343 |
+
"\"wf\"",
|
| 344 |
+
"\"uo\"",
|
| 345 |
+
"\"gb\"",
|
| 346 |
+
"\"zt\"",
|
| 347 |
+
"\"db\"",
|
| 348 |
+
"\"ko\"",
|
| 349 |
+
"\"hu\"",
|
| 350 |
+
"\"bc\"",
|
| 351 |
+
"\"pq\"",
|
| 352 |
+
"\"eb\"",
|
| 353 |
+
"\"sj\"",
|
| 354 |
+
"\"se\"",
|
| 355 |
+
"\"bt\"",
|
| 356 |
+
"\"wa\"",
|
| 357 |
+
"\"mw\"",
|
| 358 |
+
"\"xo\"",
|
| 359 |
+
"\"qx\"",
|
| 360 |
+
"\"da\"",
|
| 361 |
+
"\"wz\"",
|
| 362 |
+
"\"ok\"",
|
| 363 |
+
"\"ts\"",
|
| 364 |
+
"\"dh\"",
|
| 365 |
+
"\"sb\"",
|
| 366 |
+
"\"du\"",
|
| 367 |
+
"\"yp\"",
|
| 368 |
+
"\"dp\"",
|
| 369 |
+
"\"ub\"",
|
| 370 |
+
"\"gs\"",
|
| 371 |
+
"\"bm\""
|
| 372 |
+
],
|
| 373 |
+
"output": [
|
| 374 |
+
[
|
| 375 |
+
1,
|
| 376 |
+
2,
|
| 377 |
+
1,
|
| 378 |
+
1,
|
| 379 |
+
1,
|
| 380 |
+
1,
|
| 381 |
+
1,
|
| 382 |
+
1,
|
| 383 |
+
0,
|
| 384 |
+
1,
|
| 385 |
+
1,
|
| 386 |
+
0,
|
| 387 |
+
1,
|
| 388 |
+
0,
|
| 389 |
+
2,
|
| 390 |
+
1,
|
| 391 |
+
1,
|
| 392 |
+
0,
|
| 393 |
+
1,
|
| 394 |
+
1,
|
| 395 |
+
1,
|
| 396 |
+
1,
|
| 397 |
+
1,
|
| 398 |
+
1,
|
| 399 |
+
1,
|
| 400 |
+
1
|
| 401 |
+
],
|
| 402 |
+
[
|
| 403 |
+
1,
|
| 404 |
+
1,
|
| 405 |
+
1,
|
| 406 |
+
1,
|
| 407 |
+
1,
|
| 408 |
+
1,
|
| 409 |
+
1,
|
| 410 |
+
1,
|
| 411 |
+
0,
|
| 412 |
+
1,
|
| 413 |
+
1,
|
| 414 |
+
0,
|
| 415 |
+
1,
|
| 416 |
+
0,
|
| 417 |
+
2,
|
| 418 |
+
1,
|
| 419 |
+
1,
|
| 420 |
+
0,
|
| 421 |
+
1,
|
| 422 |
+
2,
|
| 423 |
+
1,
|
| 424 |
+
1,
|
| 425 |
+
1,
|
| 426 |
+
1,
|
| 427 |
+
1,
|
| 428 |
+
1
|
| 429 |
+
],
|
| 430 |
+
[
|
| 431 |
+
1,
|
| 432 |
+
2,
|
| 433 |
+
1,
|
| 434 |
+
1,
|
| 435 |
+
1,
|
| 436 |
+
1,
|
| 437 |
+
1,
|
| 438 |
+
1,
|
| 439 |
+
0,
|
| 440 |
+
1,
|
| 441 |
+
2,
|
| 442 |
+
0,
|
| 443 |
+
1,
|
| 444 |
+
0,
|
| 445 |
+
1,
|
| 446 |
+
1,
|
| 447 |
+
1,
|
| 448 |
+
0,
|
| 449 |
+
1,
|
| 450 |
+
1,
|
| 451 |
+
1,
|
| 452 |
+
1,
|
| 453 |
+
1,
|
| 454 |
+
1,
|
| 455 |
+
1,
|
| 456 |
+
1
|
| 457 |
+
],
|
| 458 |
+
[
|
| 459 |
+
1,
|
| 460 |
+
1,
|
| 461 |
+
1,
|
| 462 |
+
1,
|
| 463 |
+
1,
|
| 464 |
+
1,
|
| 465 |
+
1,
|
| 466 |
+
1,
|
| 467 |
+
0,
|
| 468 |
+
1,
|
| 469 |
+
2,
|
| 470 |
+
0,
|
| 471 |
+
1,
|
| 472 |
+
0,
|
| 473 |
+
1,
|
| 474 |
+
1,
|
| 475 |
+
1,
|
| 476 |
+
0,
|
| 477 |
+
1,
|
| 478 |
+
2,
|
| 479 |
+
1,
|
| 480 |
+
1,
|
| 481 |
+
1,
|
| 482 |
+
1,
|
| 483 |
+
1,
|
| 484 |
+
1
|
| 485 |
+
],
|
| 486 |
+
[
|
| 487 |
+
1,
|
| 488 |
+
1,
|
| 489 |
+
1,
|
| 490 |
+
1,
|
| 491 |
+
1,
|
| 492 |
+
1,
|
| 493 |
+
1,
|
| 494 |
+
1,
|
| 495 |
+
0,
|
| 496 |
+
1,
|
| 497 |
+
1,
|
| 498 |
+
0,
|
| 499 |
+
1,
|
| 500 |
+
0,
|
| 501 |
+
2,
|
| 502 |
+
1,
|
| 503 |
+
1,
|
| 504 |
+
0,
|
| 505 |
+
2,
|
| 506 |
+
1,
|
| 507 |
+
1,
|
| 508 |
+
1,
|
| 509 |
+
1,
|
| 510 |
+
1,
|
| 511 |
+
1,
|
| 512 |
+
1
|
| 513 |
+
],
|
| 514 |
+
[
|
| 515 |
+
1,
|
| 516 |
+
1,
|
| 517 |
+
1,
|
| 518 |
+
1,
|
| 519 |
+
1,
|
| 520 |
+
1,
|
| 521 |
+
1,
|
| 522 |
+
1,
|
| 523 |
+
0,
|
| 524 |
+
1,
|
| 525 |
+
2,
|
| 526 |
+
0,
|
| 527 |
+
1,
|
| 528 |
+
0,
|
| 529 |
+
1,
|
| 530 |
+
1,
|
| 531 |
+
1,
|
| 532 |
+
0,
|
| 533 |
+
2,
|
| 534 |
+
1,
|
| 535 |
+
1,
|
| 536 |
+
1,
|
| 537 |
+
1,
|
| 538 |
+
1,
|
| 539 |
+
1,
|
| 540 |
+
1
|
| 541 |
+
]
|
| 542 |
+
]
|
| 543 |
+
},
|
| 544 |
+
{
|
| 545 |
+
"input": [
|
| 546 |
+
"\"sk\"",
|
| 547 |
+
"\"fj\"",
|
| 548 |
+
"\"km\"",
|
| 549 |
+
"\"ql\"",
|
| 550 |
+
"\"in\"",
|
| 551 |
+
"\"ex\"",
|
| 552 |
+
"\"zp\"",
|
| 553 |
+
"\"px\"",
|
| 554 |
+
"\"dn\"",
|
| 555 |
+
"\"ej\"",
|
| 556 |
+
"\"xg\"",
|
| 557 |
+
"\"pp\"",
|
| 558 |
+
"\"yx\"",
|
| 559 |
+
"\"ay\"",
|
| 560 |
+
"\"jz\""
|
| 561 |
+
],
|
| 562 |
+
"output": [
|
| 563 |
+
[
|
| 564 |
+
1,
|
| 565 |
+
0,
|
| 566 |
+
0,
|
| 567 |
+
1,
|
| 568 |
+
1,
|
| 569 |
+
1,
|
| 570 |
+
1,
|
| 571 |
+
0,
|
| 572 |
+
1,
|
| 573 |
+
1,
|
| 574 |
+
1,
|
| 575 |
+
1,
|
| 576 |
+
1,
|
| 577 |
+
1,
|
| 578 |
+
0,
|
| 579 |
+
2,
|
| 580 |
+
1,
|
| 581 |
+
0,
|
| 582 |
+
1,
|
| 583 |
+
0,
|
| 584 |
+
0,
|
| 585 |
+
0,
|
| 586 |
+
0,
|
| 587 |
+
1,
|
| 588 |
+
1,
|
| 589 |
+
1
|
| 590 |
+
]
|
| 591 |
+
]
|
| 592 |
+
},
|
| 593 |
+
{
|
| 594 |
+
"input": [
|
| 595 |
+
"\"ex\"",
|
| 596 |
+
"\"ao\"",
|
| 597 |
+
"\"ak\"",
|
| 598 |
+
"\"dy\"",
|
| 599 |
+
"\"gr\"",
|
| 600 |
+
"\"rf\"",
|
| 601 |
+
"\"mz\"",
|
| 602 |
+
"\"rr\"",
|
| 603 |
+
"\"ch\"",
|
| 604 |
+
"\"iz\"",
|
| 605 |
+
"\"ry\"",
|
| 606 |
+
"\"xw\"",
|
| 607 |
+
"\"ju\"",
|
| 608 |
+
"\"pj\"",
|
| 609 |
+
"\"rt\"",
|
| 610 |
+
"\"di\"",
|
| 611 |
+
"\"eg\"",
|
| 612 |
+
"\"ox\"",
|
| 613 |
+
"\"ja\"",
|
| 614 |
+
"\"ct\"",
|
| 615 |
+
"\"je\"",
|
| 616 |
+
"\"fp\"",
|
| 617 |
+
"\"ku\"",
|
| 618 |
+
"\"ph\"",
|
| 619 |
+
"\"nb\"",
|
| 620 |
+
"\"gh\"",
|
| 621 |
+
"\"az\"",
|
| 622 |
+
"\"fg\"",
|
| 623 |
+
"\"tg\"",
|
| 624 |
+
"\"kc\"",
|
| 625 |
+
"\"qa\"",
|
| 626 |
+
"\"gn\"",
|
| 627 |
+
"\"oq\"",
|
| 628 |
+
"\"qs\"",
|
| 629 |
+
"\"gg\"",
|
| 630 |
+
"\"ej\"",
|
| 631 |
+
"\"ce\"",
|
| 632 |
+
"\"xl\"",
|
| 633 |
+
"\"un\"",
|
| 634 |
+
"\"av\"",
|
| 635 |
+
"\"cf\"",
|
| 636 |
+
"\"bq\"",
|
| 637 |
+
"\"uj\"",
|
| 638 |
+
"\"jq\"",
|
| 639 |
+
"\"xj\"",
|
| 640 |
+
"\"oa\"",
|
| 641 |
+
"\"km\"",
|
| 642 |
+
"\"zz\"",
|
| 643 |
+
"\"uu\"",
|
| 644 |
+
"\"hn\"",
|
| 645 |
+
"\"wj\"",
|
| 646 |
+
"\"bo\"",
|
| 647 |
+
"\"df\"",
|
| 648 |
+
"\"co\"",
|
| 649 |
+
"\"zi\"",
|
| 650 |
+
"\"cv\"",
|
| 651 |
+
"\"dm\"",
|
| 652 |
+
"\"rn\"",
|
| 653 |
+
"\"an\""
|
| 654 |
+
],
|
| 655 |
+
"output": [
|
| 656 |
+
[
|
| 657 |
+
2,
|
| 658 |
+
1,
|
| 659 |
+
1,
|
| 660 |
+
1,
|
| 661 |
+
2,
|
| 662 |
+
1,
|
| 663 |
+
2,
|
| 664 |
+
1,
|
| 665 |
+
1,
|
| 666 |
+
1,
|
| 667 |
+
1,
|
| 668 |
+
1,
|
| 669 |
+
1,
|
| 670 |
+
1,
|
| 671 |
+
1,
|
| 672 |
+
1,
|
| 673 |
+
1,
|
| 674 |
+
2,
|
| 675 |
+
1,
|
| 676 |
+
1,
|
| 677 |
+
2,
|
| 678 |
+
1,
|
| 679 |
+
1,
|
| 680 |
+
1,
|
| 681 |
+
1,
|
| 682 |
+
2
|
| 683 |
+
],
|
| 684 |
+
[
|
| 685 |
+
2,
|
| 686 |
+
1,
|
| 687 |
+
1,
|
| 688 |
+
1,
|
| 689 |
+
1,
|
| 690 |
+
1,
|
| 691 |
+
2,
|
| 692 |
+
1,
|
| 693 |
+
1,
|
| 694 |
+
2,
|
| 695 |
+
1,
|
| 696 |
+
1,
|
| 697 |
+
1,
|
| 698 |
+
1,
|
| 699 |
+
1,
|
| 700 |
+
1,
|
| 701 |
+
1,
|
| 702 |
+
2,
|
| 703 |
+
1,
|
| 704 |
+
1,
|
| 705 |
+
2,
|
| 706 |
+
1,
|
| 707 |
+
1,
|
| 708 |
+
1,
|
| 709 |
+
1,
|
| 710 |
+
2
|
| 711 |
+
]
|
| 712 |
+
]
|
| 713 |
+
}
|
| 714 |
+
],
|
| 715 |
+
"haskell_template": "supersequences :: [String] -> [[Int]]\nsupersequences words ",
|
| 716 |
+
"ocaml_template": "let supersequences (words: string list) : int list list = ",
|
| 717 |
+
"scala_template": "def supersequences(words: List[String]): List[List[Int]] = { \n \n}",
|
| 718 |
+
"java_template": "class Solution {\n public List<List<Integer>> supersequences(String[] words) {\n \n }\n}",
|
| 719 |
+
"python_template": "class Solution(object):\n def supersequences(self, words):\n \"\"\"\n :type words: List[str]\n :rtype: List[List[int]]\n \"\"\"\n "
|
| 720 |
+
}
|
frequencies_of_shortest_supersequences/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let supersequences (words: string list) : int list list = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal [[1;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0];[2;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["ab";"ba"])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal [[2;0;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["aa";"ac"])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["aa";"bb";"cc"])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["wp"; "gb"; "mv"; "ng"; "em"; "ls"; "ay"; "ah"; "xt"; "ua"; "pn"; "mg"; "fs"; "pq"; "kp"; "ja"; "hs"; "au"; "wh"; "tc"; "cm"; "ku"; "zb"; "cz"; "sm"; "bk"; "nu"; "wu"; "su"; "yh"; "rv"; "oz"; "ce"; "br"; "fy"; "jq"; "qg"; "qr"; "zz"; "xi"; "ov"; "ib"; "ci"; "cq"; "gm"; "vt"; "gq"; "lx"; "hz"; "qw"; "pp"; "oo"; "xv"; "ey"; "gc"; "sa"; "fw"; "dx"; "zv"; "ni"; "gr"; "kd"; "wg"; "yy"; "gl"; "wy"; "sn"; "bn"; "kn"; "qp"; "vg"; "rb"; "hh"; "nz"; "jx"; "mu"; "xu"; "mn"; "hy"; "mr"; "ev"; "qa"; "me"; "sq"; "dg"; "qu"; "iy"; "od"; "sf"; "jf"; "tt"; "ym"; "ki"; "wi"; "ts"; "ur"; "du"; "dd"; "dq"; "ie"; "zg"; "wc"; "bj"; "xf"; "md"; "ac"; "sx"; "ra"; "my"; "rd"; "fq"; "vy"; "bi"; "fn"; "ew"; "rf"; "fu"; "za"; "rr"; "py"; "iz"; "kk"; "pw"; "rt"; "ff"; "tw"; "fe"; "lj"; "bd"; "fz"; "re"; "mb"; "th"; "et"; "zl"; "uz"; "qh"; "be"; "kx"; "dj"; "jm"; "ga"; "zn"; "bh"; "vq"; "wn"; "qn"; "np"; "cb"; "wl"; "ll"; "st"; "vl"; "vd"; "tq"; "no"; "lp"; "ho"; "nt"; "wv"; "lz"; "ys"; "qe"; "vh"; "ge"; "dm"; "mz"; "uo"; "lt"; "hv"; "kh"; "jr"; "db"; "nh"; "pg"; "qv"; "qf"; "vp"; "va"; "xm"; "ry"; "to"; "li"; "sk"; "lq"; "bt"; "al"; "we"; "fb"; "ea"; "wd"; "up"; "az"; "vn"; "hc"; "ui"; "tp"; "ql"; "hg"; "lk"; "tm"; "pi"; "zs"; "aj"; "tl"; "td"; "kq"; "sr"; "so"; "ou"; "gi"; "tn"; "ha"; "yp"; "rs"; "dp"; "pl"; "ub"; "ot"; "na"; "oj"; "nn"; "lm"; "xd"; "cv"; "en"; "pd"])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["kj"; "kn"; "eb"; "vo"; "hg"; "jn"; "qd"; "ye"; "ai"; "ux"; "cg"; "lh"; "qg"; "ls"; "lf"; "wd"; "pf"])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["jv"; "vx"; "jo"; "wf"; "uo"; "gb"; "zt"; "db"; "ko"; "hu"; "bc"; "pq"; "eb"; "sj"; "se"; "bt"; "wa"; "mw"; "xo"; "qx"; "da"; "wz"; "ok"; "ts"; "dh"; "sb"; "du"; "yp"; "dp"; "ub"; "gs"; "bm"])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["sk"; "fj"; "km"; "ql"; "in"; "ex"; "zp"; "px"; "dn"; "ej"; "xg"; "pp"; "yx"; "ay"; "jz"])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal [[2;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0]] (supersequences ["ex"; "ao"; "ak"; "dy"; "gr"; "rf"; "mz"; "rr"; "ch"; "iz"; "ry"; "xw"; "ju"; "pj"; "rt"; "di"; "eg"; "ox"; "ja"; "ct"; "je"; "fp"; "ku"; "ph"; "nb"; "gh"; "az"; "fg"; "tg"; "kc"; "qa"; "gn"; "oq"; "qs"; "gg"; "ej"; "ce"; "xl"; "un"; "av"; "cf"; "bq"; "uj"; "jq"; "xj"; "oa"; "km"; "zz"; "uu"; "hn"; "wj"; "bo"; "df"; "co"; "zi"; "cv"; "dm"; "rn"; "an"])
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
(* Grouping test cases *)
|
| 30 |
+
let suite = "Test Suite for supersequences" >::: [
|
| 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
|
frequencies_of_shortest_supersequences/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.supersequences(List("ab","ba")), List(List(1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),List(2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.supersequences(List("aa","ac")), List(List(2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.supersequences(List("aa","bb","cc")), List(List(2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)))
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.supersequences("wp","gb","mv","ng","em","ls","ay","ah","xt","ua","pn","mg","fs","pq","kp","ja","hs","au","wh","tc","cm","ku","zb","cz","sm","bk","nu","wu","su","yh","rv","oz","ce","br","fy","jq","qg","qr","zz","xi","ov","ib","ci","cq","gm","vt","gq","lx","hz","qw","pp","oo","xv","ey","gc","sa","fw","dx","zv","ni","gr","kd","wg","yy","gl","wy","sn","bn","kn","qp","vg","rb","hh","nz","jx","mu","xu","mn","hy","mr","ev","qa","me","sq","dg","qu","iy","od","sf","jf","tt","ym","ki","wi","ts","ur","du","dd","dq","ie","zg","wc","bj","xf","md","ac","sx","ra","my","rd","fq","vy","bi","fn","ew","rf","fu","za","rr","py","iz","kk","pw","rt","ff","tw","fe","lj","bd","fz","re","mb","th","et","zl","uz","qh","be","kx","dj","jm","ga","zn","bh","vq","wn","qn","np","cb","wl","ll","st","vl","vd","tq","no","lp","ho","nt","wv","lz","ys","qe","vh","ge","dm","mz","uo","lt","hv","kh","jr","db","nh","pg","qv","qf","vp","va","xm","ry","to","li","sk","lq","bt","al","we","fb","ea","wd","up","az","vn","hc","ui","tp","ql","hg","lk","tm","pi","zs","aj","tl","td","kq","sr","so","ou","gi","tn","ha","yp","rs","dp","pl","ub","ot","na","oj","nn","lm","xd","cv","en","pd"), List(List(2,2,1,2,2,2,2,2,1,1,2,2,1,2,2,2,2,2,1,2,1,1,1,1,2,2)))
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.supersequences("kj","kn","eb","vo","hg","jn","qd","ye","ai","ux","cg","lh","qg","ls","lf","wd","pf"), List(List(1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,1,0)))
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.supersequences("jv","vx","jo","wf","uo","gb","zt","db","ko","hu","bc","pq","eb","sj","se","bt","wa","mw","xo","qx","da","wz","ok","ts","dh","sb","du","yp","dp","ub","gs","bm"), List(List(1,2,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,1,1,1,1,1,1,1,1),List(1,1,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,1,2,1,1,1,1,1,1),List(1,2,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1),List(1,1,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,1,2,1,1,1,1,1,1),List(1,1,1,1,1,1,1,1,0,1,1,0,1,0,2,1,1,0,2,1,1,1,1,1,1,1),List(1,1,1,1,1,1,1,1,0,1,2,0,1,0,1,1,1,0,2,1,1,1,1,1,1,1)))
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.supersequences("sk","fj","km","ql","in","ex","zp","px","dn","ej","xg","pp","yx","ay","jz"), List(List(1,0,0,1,1,1,1,0,1,1,1,1,1,1,0,2,1,0,1,0,0,0,0,1,1,1)))
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.supersequences("ex","ao","ak","dy","gr","rf","mz","rr","ch","iz","ry","xw","ju","pj","rt","di","eg","ox","ja","ct","je","fp","ku","ph","nb","gh","az","fg","tg","kc","qa","gn","oq","qs","gg","ej","ce","xl","un","av","cf","bq","uj","jq","xj","oa","km","zz","uu","hn","wj","bo","df","co","zi","cv","dm","rn","an"), List(List(2,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2),List(2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2)))
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
frog_jump_ii/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
frog_jump_ii/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 (maxJump [0,2,5,6,7])," 5 (maxJump [0,2,5,6,7]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maxJump [0,3,9])," 9 (maxJump [0,3,9]))
|
| 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
|
frog_jump_ii/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(5, maxJump(new ArrayList<>(Arrays.asList(0,2,5,6,7))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(9, maxJump(new ArrayList<>(Arrays.asList(0,3,9))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
frog_jump_ii/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:601c46cb5490a3720ad87b1c04857993b4ce865015ef600eb97e674613901a2e
|
| 3 |
+
size 17025027
|
frog_jump_ii/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 5 (maxJump [0;2;5;6;7])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 9 (maxJump [0;3;9])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for maxJump" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
frog_jump_ii/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.maxJump(List(0,2,5,6,7)), 5)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.maxJump(List(0,3,9)), 9)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
fruits_into_baskets_ii/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 (numOfUnplacedFruits [4,2,5] [3,5,4])," 1 (numOfUnplacedFruits [4,2,5] [3,5,4]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numOfUnplacedFruits [3,6,1] [6,4,7])," 0 (numOfUnplacedFruits [3,6,1] [6,4,7]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (numOfUnplacedFruits [903, 138, 352, 970, 513, 942, 730, 780, 235, 391, 839, 225, 143, 988, 817, 576, 130, 910, 938, 28, 572, 400, 583, 72, 393, 962, 322, 515, 913, 122, 529, 637, 647, 887, 841, 257, 843, 786, 120, 508, 779, 252, 77, 567, 396, 1000, 151, 639, 634, 641, 479, 222, 975, 309, 652, 283, 328, 980, 28, 596, 73, 753, 785, 598, 64, 435, 627, 603, 119, 408, 795, 183, 76, 83, 274, 354, 789, 660, 664, 9, 349, 774, 592, 654, 723, 282, 741, 946, 420, 53, 950] [602, 189, 806, 622, 620, 991, 466, 388, 135, 605, 166, 967, 185, 35, 751, 103, 638, 255, 785, 185, 150, 260, 664, 294, 863, 785, 684, 395, 22, 339, 667, 816, 877, 65, 396, 901, 847, 974, 722, 315, 962, 577, 938, 160, 896, 548, 542, 852, 34, 20, 531, 404, 248, 622, 126, 451, 543, 814, 631, 974, 423, 110, 955, 554, 175, 955, 577, 298, 186, 894, 145, 250, 659, 457, 767, 25, 447, 658, 957, 402, 217, 557, 150, 598, 636, 284, 385, 414, 924, 300, 214])," 16 (numOfUnplacedFruits [903, 138, 352, 970, 513, 942, 730, 780, 235, 391, 839, 225, 143, 988, 817, 576, 130, 910, 938, 28, 572, 400, 583, 72, 393, 962, 322, 515, 913, 122, 529, 637, 647, 887, 841, 257, 843, 786, 120, 508, 779, 252, 77, 567, 396, 1000, 151, 639, 634, 641, 479, 222, 975, 309, 652, 283, 328, 980, 28, 596, 73, 753, 785, 598, 64, 435, 627, 603, 119, 408, 795, 183, 76, 83, 274, 354, 789, 660, 664, 9, 349, 774, 592, 654, 723, 282, 741, 946, 420, 53, 950] [602, 189, 806, 622, 620, 991, 466, 388, 135, 605, 166, 967, 185, 35, 751, 103, 638, 255, 785, 185, 150, 260, 664, 294, 863, 785, 684, 395, 22, 339, 667, 816, 877, 65, 396, 901, 847, 974, 722, 315, 962, 577, 938, 160, 896, 548, 542, 852, 34, 20, 531, 404, 248, 622, 126, 451, 543, 814, 631, 974, 423, 110, 955, 554, 175, 955, 577, 298, 186, 894, 145, 250, 659, 457, 767, 25, 447, 658, 957, 402, 217, 557, 150, 598, 636, 284, 385, 414, 924, 300, 214]))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (numOfUnplacedFruits [411, 645, 458, 749, 266, 472, 819, 468, 188, 631, 451, 513, 368, 790, 35, 677, 988, 396, 770, 269, 917, 46, 506, 582, 682, 904, 502, 182, 211, 160, 218, 548, 403, 18, 961, 351] [668, 1000, 676, 24, 389, 903, 592, 896, 30, 343, 765, 537, 241, 850, 579, 566, 350, 757, 340, 88, 814, 233, 215, 371, 916, 836, 245, 940, 131, 936, 30, 627, 113, 444, 129, 111])," 7 (numOfUnplacedFruits [411, 645, 458, 749, 266, 472, 819, 468, 188, 631, 451, 513, 368, 790, 35, 677, 988, 396, 770, 269, 917, 46, 506, 582, 682, 904, 502, 182, 211, 160, 218, 548, 403, 18, 961, 351] [668, 1000, 676, 24, 389, 903, 592, 896, 30, 343, 765, 537, 241, 850, 579, 566, 350, 757, 340, 88, 814, 233, 215, 371, 916, 836, 245, 940, 131, 936, 30, 627, 113, 444, 129, 111]))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (numOfUnplacedFruits [478, 114, 219, 666, 231, 829, 926, 125, 35, 578, 486, 207, 647, 154, 57, 717, 210, 591, 347, 263, 329, 622, 565, 965, 732, 86, 517, 972, 791, 614, 488, 194, 42, 395, 344, 832, 192, 575, 190, 675, 549, 418, 426, 637, 660, 337, 485, 351, 629, 757, 909, 963, 129, 139, 708, 504, 192, 129, 306, 376, 640, 517, 642, 598, 852] [610, 739, 185, 884, 715, 976, 950, 64, 780, 83, 179, 397, 911, 683, 560, 723, 946, 161, 611, 524, 305, 470, 70, 916, 646, 577, 161, 402, 491, 322, 242, 466, 920, 151, 342, 545, 570, 685, 823, 245, 152, 332, 180, 806, 139, 418, 206, 377, 389, 256, 852, 691, 225, 823, 69, 873, 409, 514, 307, 632, 612, 502, 643, 544, 934])," 9 (numOfUnplacedFruits [478, 114, 219, 666, 231, 829, 926, 125, 35, 578, 486, 207, 647, 154, 57, 717, 210, 591, 347, 263, 329, 622, 565, 965, 732, 86, 517, 972, 791, 614, 488, 194, 42, 395, 344, 832, 192, 575, 190, 675, 549, 418, 426, 637, 660, 337, 485, 351, 629, 757, 909, 963, 129, 139, 708, 504, 192, 129, 306, 376, 640, 517, 642, 598, 852] [610, 739, 185, 884, 715, 976, 950, 64, 780, 83, 179, 397, 911, 683, 560, 723, 946, 161, 611, 524, 305, 470, 70, 916, 646, 577, 161, 402, 491, 322, 242, 466, 920, 151, 342, 545, 570, 685, 823, 245, 152, 332, 180, 806, 139, 418, 206, 377, 389, 256, 852, 691, 225, 823, 69, 873, 409, 514, 307, 632, 612, 502, 643, 544, 934]))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (numOfUnplacedFruits [855, 426, 606, 929, 591, 33, 138, 80, 985, 56, 812, 901, 795, 995, 870, 983, 420, 106, 222, 186, 418, 32, 901, 91, 429, 195, 230, 875, 806, 419, 54, 859, 746, 681, 742, 992, 515, 342, 712, 222, 278, 77, 558, 529, 821, 176, 750, 372, 635, 370, 532, 237, 970, 392, 629, 588, 713, 851, 639, 90, 665, 622, 561, 93, 623, 364, 36, 9, 783, 607, 642, 983, 347, 490, 208, 546, 520, 99, 465, 31, 218, 431, 376, 771, 530, 344, 937, 565, 457, 643, 471, 904, 545, 213, 153] [215, 175, 405, 333, 903, 845, 42, 873, 746, 922, 572, 814, 259, 309, 611, 331, 767, 111, 377, 736, 733, 599, 29, 21, 801, 461, 51, 159, 445, 421, 278, 593, 69, 258, 60, 772, 393, 73, 685, 970, 890, 175, 938, 220, 516, 703, 891, 991, 883, 166, 303, 830, 291, 743, 15, 837, 267, 403, 563, 194, 135, 469, 296, 43, 59, 966, 528, 135, 187, 635, 376, 421, 605, 929, 161, 243, 212, 852, 661, 92, 844, 902, 28, 930, 766, 352, 324, 104, 403, 755, 27, 299, 114, 480, 958])," 22 (numOfUnplacedFruits [855, 426, 606, 929, 591, 33, 138, 80, 985, 56, 812, 901, 795, 995, 870, 983, 420, 106, 222, 186, 418, 32, 901, 91, 429, 195, 230, 875, 806, 419, 54, 859, 746, 681, 742, 992, 515, 342, 712, 222, 278, 77, 558, 529, 821, 176, 750, 372, 635, 370, 532, 237, 970, 392, 629, 588, 713, 851, 639, 90, 665, 622, 561, 93, 623, 364, 36, 9, 783, 607, 642, 983, 347, 490, 208, 546, 520, 99, 465, 31, 218, 431, 376, 771, 530, 344, 937, 565, 457, 643, 471, 904, 545, 213, 153] [215, 175, 405, 333, 903, 845, 42, 873, 746, 922, 572, 814, 259, 309, 611, 331, 767, 111, 377, 736, 733, 599, 29, 21, 801, 461, 51, 159, 445, 421, 278, 593, 69, 258, 60, 772, 393, 73, 685, 970, 890, 175, 938, 220, 516, 703, 891, 991, 883, 166, 303, 830, 291, 743, 15, 837, 267, 403, 563, 194, 135, 469, 296, 43, 59, 966, 528, 135, 187, 635, 376, 421, 605, 929, 161, 243, 212, 852, 661, 92, 844, 902, 28, 930, 766, 352, 324, 104, 403, 755, 27, 299, 114, 480, 958]))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (numOfUnplacedFruits [287, 961, 506, 125, 140, 979, 604, 894, 907, 555, 757, 810, 385, 945, 61, 154, 725, 153, 921, 275, 787, 36, 758, 517, 147, 109, 678, 401] [328, 688, 564, 547, 627, 951, 63, 598, 455, 590, 417, 577, 712, 65, 449, 695, 672, 943, 120, 854, 911, 781, 575, 189, 616, 491, 76, 341])," 7 (numOfUnplacedFruits [287, 961, 506, 125, 140, 979, 604, 894, 907, 555, 757, 810, 385, 945, 61, 154, 725, 153, 921, 275, 787, 36, 758, 517, 147, 109, 678, 401] [328, 688, 564, 547, 627, 951, 63, 598, 455, 590, 417, 577, 712, 65, 449, 695, 672, 943, 120, 854, 911, 781, 575, 189, 616, 491, 76, 341]))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (numOfUnplacedFruits [917, 76, 164, 865, 176, 616, 762] [302, 83, 110, 124, 484, 733, 580])," 4 (numOfUnplacedFruits [917, 76, 164, 865, 176, 616, 762] [302, 83, 110, 124, 484, 733, 580]))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (numOfUnplacedFruits [246, 601, 986, 554, 800, 782, 872, 94, 654, 401, 714, 573, 610, 60, 974, 934, 32, 525, 124, 447, 381, 651, 860, 67, 892, 123, 314] [613, 866, 771, 777, 788, 874, 912, 89, 32, 948, 61, 780, 582, 765, 598, 892, 661, 720, 347, 64, 695, 568, 606, 336, 505, 277, 470])," 6 (numOfUnplacedFruits [246, 601, 986, 554, 800, 782, 872, 94, 654, 401, 714, 573, 610, 60, 974, 934, 32, 525, 124, 447, 381, 651, 860, 67, 892, 123, 314] [613, 866, 771, 777, 788, 874, 912, 89, 32, 948, 61, 780, 582, 765, 598, 892, 661, 720, 347, 64, 695, 568, 606, 336, 505, 277, 470]))
|
| 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
|
fruits_into_baskets_ii/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(1, numOfUnplacedFruits(new ArrayList<>(Arrays.asList(4,2,5)), new ArrayList<>(Arrays.asList(3,5,4))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(0, numOfUnplacedFruits(new ArrayList<>(Arrays.asList(3,6,1)), new ArrayList<>(Arrays.asList(6,4,7))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
fruits_into_baskets_ii/meta.json
ADDED
|
@@ -0,0 +1,1047 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3790,
|
| 3 |
+
"name": "fruits_into_baskets_ii",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/fruits-into-baskets-ii/",
|
| 6 |
+
"date": "2025-03-02 00:00:00",
|
| 7 |
+
"task_description": "You are given two arrays of integers, `fruits` and `baskets`, each of length `n`, where `fruits[i]` represents the **quantity** of the `ith` type of fruit, and `baskets[j]` represents the **capacity** of the `jth` basket. From left to right, place the fruits according to these rules: Each fruit type must be placed in the **leftmost available basket** with a capacity **greater than or equal** to the quantity of that fruit type. Each basket can hold only one type of fruit. If a fruit type cannot be placed in any basket, it remains unplaced. Return the number of fruit types that remain unplaced after all possible allocations are made. **Example 1:** **Input:** fruits = [4,2,5], baskets = [3,5,4] **Output:** 1 **Explanation:** `fruits[0] = 4` is placed in `baskets[1] = 5`. `fruits[1] = 2` is placed in `baskets[0] = 3`. `fruits[2] = 5` cannot be placed in `baskets[2] = 4`. Since one fruit type remains unplaced, we return 1. **Example 2:** **Input:** fruits = [3,6,1], baskets = [6,4,7] **Output:** 0 **Explanation:** `fruits[0] = 3` is placed in `baskets[0] = 6`. `fruits[1] = 6` cannot be placed in `baskets[1] = 4` (insufficient capacity) but can be placed in the next available basket, `baskets[2] = 7`. `fruits[2] = 1` is placed in `baskets[1] = 4`. Since all fruits are successfully placed, we return 0. **Constraints:** `n == fruits.length == baskets.length` `1 <= n <= 100` `1 <= fruits[i], baskets[i] <= 1000`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "fruits = [4,2,5], baskets = [3,5,4]",
|
| 12 |
+
"output": "1 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "fruits = [3,6,1], baskets = [6,4,7]",
|
| 17 |
+
"output": "0 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
903,
|
| 25 |
+
138,
|
| 26 |
+
352,
|
| 27 |
+
970,
|
| 28 |
+
513,
|
| 29 |
+
942,
|
| 30 |
+
730,
|
| 31 |
+
780,
|
| 32 |
+
235,
|
| 33 |
+
391,
|
| 34 |
+
839,
|
| 35 |
+
225,
|
| 36 |
+
143,
|
| 37 |
+
988,
|
| 38 |
+
817,
|
| 39 |
+
576,
|
| 40 |
+
130,
|
| 41 |
+
910,
|
| 42 |
+
938,
|
| 43 |
+
28,
|
| 44 |
+
572,
|
| 45 |
+
400,
|
| 46 |
+
583,
|
| 47 |
+
72,
|
| 48 |
+
393,
|
| 49 |
+
962,
|
| 50 |
+
322,
|
| 51 |
+
515,
|
| 52 |
+
913,
|
| 53 |
+
122,
|
| 54 |
+
529,
|
| 55 |
+
637,
|
| 56 |
+
647,
|
| 57 |
+
887,
|
| 58 |
+
841,
|
| 59 |
+
257,
|
| 60 |
+
843,
|
| 61 |
+
786,
|
| 62 |
+
120,
|
| 63 |
+
508,
|
| 64 |
+
779,
|
| 65 |
+
252,
|
| 66 |
+
77,
|
| 67 |
+
567,
|
| 68 |
+
396,
|
| 69 |
+
1000,
|
| 70 |
+
151,
|
| 71 |
+
639,
|
| 72 |
+
634,
|
| 73 |
+
641,
|
| 74 |
+
479,
|
| 75 |
+
222,
|
| 76 |
+
975,
|
| 77 |
+
309,
|
| 78 |
+
652,
|
| 79 |
+
283,
|
| 80 |
+
328,
|
| 81 |
+
980,
|
| 82 |
+
28,
|
| 83 |
+
596,
|
| 84 |
+
73,
|
| 85 |
+
753,
|
| 86 |
+
785,
|
| 87 |
+
598,
|
| 88 |
+
64,
|
| 89 |
+
435,
|
| 90 |
+
627,
|
| 91 |
+
603,
|
| 92 |
+
119,
|
| 93 |
+
408,
|
| 94 |
+
795,
|
| 95 |
+
183,
|
| 96 |
+
76,
|
| 97 |
+
83,
|
| 98 |
+
274,
|
| 99 |
+
354,
|
| 100 |
+
789,
|
| 101 |
+
660,
|
| 102 |
+
664,
|
| 103 |
+
9,
|
| 104 |
+
349,
|
| 105 |
+
774,
|
| 106 |
+
592,
|
| 107 |
+
654,
|
| 108 |
+
723,
|
| 109 |
+
282,
|
| 110 |
+
741,
|
| 111 |
+
946,
|
| 112 |
+
420,
|
| 113 |
+
53,
|
| 114 |
+
950
|
| 115 |
+
],
|
| 116 |
+
[
|
| 117 |
+
602,
|
| 118 |
+
189,
|
| 119 |
+
806,
|
| 120 |
+
622,
|
| 121 |
+
620,
|
| 122 |
+
991,
|
| 123 |
+
466,
|
| 124 |
+
388,
|
| 125 |
+
135,
|
| 126 |
+
605,
|
| 127 |
+
166,
|
| 128 |
+
967,
|
| 129 |
+
185,
|
| 130 |
+
35,
|
| 131 |
+
751,
|
| 132 |
+
103,
|
| 133 |
+
638,
|
| 134 |
+
255,
|
| 135 |
+
785,
|
| 136 |
+
185,
|
| 137 |
+
150,
|
| 138 |
+
260,
|
| 139 |
+
664,
|
| 140 |
+
294,
|
| 141 |
+
863,
|
| 142 |
+
785,
|
| 143 |
+
684,
|
| 144 |
+
395,
|
| 145 |
+
22,
|
| 146 |
+
339,
|
| 147 |
+
667,
|
| 148 |
+
816,
|
| 149 |
+
877,
|
| 150 |
+
65,
|
| 151 |
+
396,
|
| 152 |
+
901,
|
| 153 |
+
847,
|
| 154 |
+
974,
|
| 155 |
+
722,
|
| 156 |
+
315,
|
| 157 |
+
962,
|
| 158 |
+
577,
|
| 159 |
+
938,
|
| 160 |
+
160,
|
| 161 |
+
896,
|
| 162 |
+
548,
|
| 163 |
+
542,
|
| 164 |
+
852,
|
| 165 |
+
34,
|
| 166 |
+
20,
|
| 167 |
+
531,
|
| 168 |
+
404,
|
| 169 |
+
248,
|
| 170 |
+
622,
|
| 171 |
+
126,
|
| 172 |
+
451,
|
| 173 |
+
543,
|
| 174 |
+
814,
|
| 175 |
+
631,
|
| 176 |
+
974,
|
| 177 |
+
423,
|
| 178 |
+
110,
|
| 179 |
+
955,
|
| 180 |
+
554,
|
| 181 |
+
175,
|
| 182 |
+
955,
|
| 183 |
+
577,
|
| 184 |
+
298,
|
| 185 |
+
186,
|
| 186 |
+
894,
|
| 187 |
+
145,
|
| 188 |
+
250,
|
| 189 |
+
659,
|
| 190 |
+
457,
|
| 191 |
+
767,
|
| 192 |
+
25,
|
| 193 |
+
447,
|
| 194 |
+
658,
|
| 195 |
+
957,
|
| 196 |
+
402,
|
| 197 |
+
217,
|
| 198 |
+
557,
|
| 199 |
+
150,
|
| 200 |
+
598,
|
| 201 |
+
636,
|
| 202 |
+
284,
|
| 203 |
+
385,
|
| 204 |
+
414,
|
| 205 |
+
924,
|
| 206 |
+
300,
|
| 207 |
+
214
|
| 208 |
+
]
|
| 209 |
+
],
|
| 210 |
+
"output": 16
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"input": [
|
| 214 |
+
[
|
| 215 |
+
411,
|
| 216 |
+
645,
|
| 217 |
+
458,
|
| 218 |
+
749,
|
| 219 |
+
266,
|
| 220 |
+
472,
|
| 221 |
+
819,
|
| 222 |
+
468,
|
| 223 |
+
188,
|
| 224 |
+
631,
|
| 225 |
+
451,
|
| 226 |
+
513,
|
| 227 |
+
368,
|
| 228 |
+
790,
|
| 229 |
+
35,
|
| 230 |
+
677,
|
| 231 |
+
988,
|
| 232 |
+
396,
|
| 233 |
+
770,
|
| 234 |
+
269,
|
| 235 |
+
917,
|
| 236 |
+
46,
|
| 237 |
+
506,
|
| 238 |
+
582,
|
| 239 |
+
682,
|
| 240 |
+
904,
|
| 241 |
+
502,
|
| 242 |
+
182,
|
| 243 |
+
211,
|
| 244 |
+
160,
|
| 245 |
+
218,
|
| 246 |
+
548,
|
| 247 |
+
403,
|
| 248 |
+
18,
|
| 249 |
+
961,
|
| 250 |
+
351
|
| 251 |
+
],
|
| 252 |
+
[
|
| 253 |
+
668,
|
| 254 |
+
1000,
|
| 255 |
+
676,
|
| 256 |
+
24,
|
| 257 |
+
389,
|
| 258 |
+
903,
|
| 259 |
+
592,
|
| 260 |
+
896,
|
| 261 |
+
30,
|
| 262 |
+
343,
|
| 263 |
+
765,
|
| 264 |
+
537,
|
| 265 |
+
241,
|
| 266 |
+
850,
|
| 267 |
+
579,
|
| 268 |
+
566,
|
| 269 |
+
350,
|
| 270 |
+
757,
|
| 271 |
+
340,
|
| 272 |
+
88,
|
| 273 |
+
814,
|
| 274 |
+
233,
|
| 275 |
+
215,
|
| 276 |
+
371,
|
| 277 |
+
916,
|
| 278 |
+
836,
|
| 279 |
+
245,
|
| 280 |
+
940,
|
| 281 |
+
131,
|
| 282 |
+
936,
|
| 283 |
+
30,
|
| 284 |
+
627,
|
| 285 |
+
113,
|
| 286 |
+
444,
|
| 287 |
+
129,
|
| 288 |
+
111
|
| 289 |
+
]
|
| 290 |
+
],
|
| 291 |
+
"output": 7
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"input": [
|
| 295 |
+
[
|
| 296 |
+
478,
|
| 297 |
+
114,
|
| 298 |
+
219,
|
| 299 |
+
666,
|
| 300 |
+
231,
|
| 301 |
+
829,
|
| 302 |
+
926,
|
| 303 |
+
125,
|
| 304 |
+
35,
|
| 305 |
+
578,
|
| 306 |
+
486,
|
| 307 |
+
207,
|
| 308 |
+
647,
|
| 309 |
+
154,
|
| 310 |
+
57,
|
| 311 |
+
717,
|
| 312 |
+
210,
|
| 313 |
+
591,
|
| 314 |
+
347,
|
| 315 |
+
263,
|
| 316 |
+
329,
|
| 317 |
+
622,
|
| 318 |
+
565,
|
| 319 |
+
965,
|
| 320 |
+
732,
|
| 321 |
+
86,
|
| 322 |
+
517,
|
| 323 |
+
972,
|
| 324 |
+
791,
|
| 325 |
+
614,
|
| 326 |
+
488,
|
| 327 |
+
194,
|
| 328 |
+
42,
|
| 329 |
+
395,
|
| 330 |
+
344,
|
| 331 |
+
832,
|
| 332 |
+
192,
|
| 333 |
+
575,
|
| 334 |
+
190,
|
| 335 |
+
675,
|
| 336 |
+
549,
|
| 337 |
+
418,
|
| 338 |
+
426,
|
| 339 |
+
637,
|
| 340 |
+
660,
|
| 341 |
+
337,
|
| 342 |
+
485,
|
| 343 |
+
351,
|
| 344 |
+
629,
|
| 345 |
+
757,
|
| 346 |
+
909,
|
| 347 |
+
963,
|
| 348 |
+
129,
|
| 349 |
+
139,
|
| 350 |
+
708,
|
| 351 |
+
504,
|
| 352 |
+
192,
|
| 353 |
+
129,
|
| 354 |
+
306,
|
| 355 |
+
376,
|
| 356 |
+
640,
|
| 357 |
+
517,
|
| 358 |
+
642,
|
| 359 |
+
598,
|
| 360 |
+
852
|
| 361 |
+
],
|
| 362 |
+
[
|
| 363 |
+
610,
|
| 364 |
+
739,
|
| 365 |
+
185,
|
| 366 |
+
884,
|
| 367 |
+
715,
|
| 368 |
+
976,
|
| 369 |
+
950,
|
| 370 |
+
64,
|
| 371 |
+
780,
|
| 372 |
+
83,
|
| 373 |
+
179,
|
| 374 |
+
397,
|
| 375 |
+
911,
|
| 376 |
+
683,
|
| 377 |
+
560,
|
| 378 |
+
723,
|
| 379 |
+
946,
|
| 380 |
+
161,
|
| 381 |
+
611,
|
| 382 |
+
524,
|
| 383 |
+
305,
|
| 384 |
+
470,
|
| 385 |
+
70,
|
| 386 |
+
916,
|
| 387 |
+
646,
|
| 388 |
+
577,
|
| 389 |
+
161,
|
| 390 |
+
402,
|
| 391 |
+
491,
|
| 392 |
+
322,
|
| 393 |
+
242,
|
| 394 |
+
466,
|
| 395 |
+
920,
|
| 396 |
+
151,
|
| 397 |
+
342,
|
| 398 |
+
545,
|
| 399 |
+
570,
|
| 400 |
+
685,
|
| 401 |
+
823,
|
| 402 |
+
245,
|
| 403 |
+
152,
|
| 404 |
+
332,
|
| 405 |
+
180,
|
| 406 |
+
806,
|
| 407 |
+
139,
|
| 408 |
+
418,
|
| 409 |
+
206,
|
| 410 |
+
377,
|
| 411 |
+
389,
|
| 412 |
+
256,
|
| 413 |
+
852,
|
| 414 |
+
691,
|
| 415 |
+
225,
|
| 416 |
+
823,
|
| 417 |
+
69,
|
| 418 |
+
873,
|
| 419 |
+
409,
|
| 420 |
+
514,
|
| 421 |
+
307,
|
| 422 |
+
632,
|
| 423 |
+
612,
|
| 424 |
+
502,
|
| 425 |
+
643,
|
| 426 |
+
544,
|
| 427 |
+
934
|
| 428 |
+
]
|
| 429 |
+
],
|
| 430 |
+
"output": 9
|
| 431 |
+
},
|
| 432 |
+
{
|
| 433 |
+
"input": [
|
| 434 |
+
[
|
| 435 |
+
855,
|
| 436 |
+
426,
|
| 437 |
+
606,
|
| 438 |
+
929,
|
| 439 |
+
591,
|
| 440 |
+
33,
|
| 441 |
+
138,
|
| 442 |
+
80,
|
| 443 |
+
985,
|
| 444 |
+
56,
|
| 445 |
+
812,
|
| 446 |
+
901,
|
| 447 |
+
795,
|
| 448 |
+
995,
|
| 449 |
+
870,
|
| 450 |
+
983,
|
| 451 |
+
420,
|
| 452 |
+
106,
|
| 453 |
+
222,
|
| 454 |
+
186,
|
| 455 |
+
418,
|
| 456 |
+
32,
|
| 457 |
+
901,
|
| 458 |
+
91,
|
| 459 |
+
429,
|
| 460 |
+
195,
|
| 461 |
+
230,
|
| 462 |
+
875,
|
| 463 |
+
806,
|
| 464 |
+
419,
|
| 465 |
+
54,
|
| 466 |
+
859,
|
| 467 |
+
746,
|
| 468 |
+
681,
|
| 469 |
+
742,
|
| 470 |
+
992,
|
| 471 |
+
515,
|
| 472 |
+
342,
|
| 473 |
+
712,
|
| 474 |
+
222,
|
| 475 |
+
278,
|
| 476 |
+
77,
|
| 477 |
+
558,
|
| 478 |
+
529,
|
| 479 |
+
821,
|
| 480 |
+
176,
|
| 481 |
+
750,
|
| 482 |
+
372,
|
| 483 |
+
635,
|
| 484 |
+
370,
|
| 485 |
+
532,
|
| 486 |
+
237,
|
| 487 |
+
970,
|
| 488 |
+
392,
|
| 489 |
+
629,
|
| 490 |
+
588,
|
| 491 |
+
713,
|
| 492 |
+
851,
|
| 493 |
+
639,
|
| 494 |
+
90,
|
| 495 |
+
665,
|
| 496 |
+
622,
|
| 497 |
+
561,
|
| 498 |
+
93,
|
| 499 |
+
623,
|
| 500 |
+
364,
|
| 501 |
+
36,
|
| 502 |
+
9,
|
| 503 |
+
783,
|
| 504 |
+
607,
|
| 505 |
+
642,
|
| 506 |
+
983,
|
| 507 |
+
347,
|
| 508 |
+
490,
|
| 509 |
+
208,
|
| 510 |
+
546,
|
| 511 |
+
520,
|
| 512 |
+
99,
|
| 513 |
+
465,
|
| 514 |
+
31,
|
| 515 |
+
218,
|
| 516 |
+
431,
|
| 517 |
+
376,
|
| 518 |
+
771,
|
| 519 |
+
530,
|
| 520 |
+
344,
|
| 521 |
+
937,
|
| 522 |
+
565,
|
| 523 |
+
457,
|
| 524 |
+
643,
|
| 525 |
+
471,
|
| 526 |
+
904,
|
| 527 |
+
545,
|
| 528 |
+
213,
|
| 529 |
+
153
|
| 530 |
+
],
|
| 531 |
+
[
|
| 532 |
+
215,
|
| 533 |
+
175,
|
| 534 |
+
405,
|
| 535 |
+
333,
|
| 536 |
+
903,
|
| 537 |
+
845,
|
| 538 |
+
42,
|
| 539 |
+
873,
|
| 540 |
+
746,
|
| 541 |
+
922,
|
| 542 |
+
572,
|
| 543 |
+
814,
|
| 544 |
+
259,
|
| 545 |
+
309,
|
| 546 |
+
611,
|
| 547 |
+
331,
|
| 548 |
+
767,
|
| 549 |
+
111,
|
| 550 |
+
377,
|
| 551 |
+
736,
|
| 552 |
+
733,
|
| 553 |
+
599,
|
| 554 |
+
29,
|
| 555 |
+
21,
|
| 556 |
+
801,
|
| 557 |
+
461,
|
| 558 |
+
51,
|
| 559 |
+
159,
|
| 560 |
+
445,
|
| 561 |
+
421,
|
| 562 |
+
278,
|
| 563 |
+
593,
|
| 564 |
+
69,
|
| 565 |
+
258,
|
| 566 |
+
60,
|
| 567 |
+
772,
|
| 568 |
+
393,
|
| 569 |
+
73,
|
| 570 |
+
685,
|
| 571 |
+
970,
|
| 572 |
+
890,
|
| 573 |
+
175,
|
| 574 |
+
938,
|
| 575 |
+
220,
|
| 576 |
+
516,
|
| 577 |
+
703,
|
| 578 |
+
891,
|
| 579 |
+
991,
|
| 580 |
+
883,
|
| 581 |
+
166,
|
| 582 |
+
303,
|
| 583 |
+
830,
|
| 584 |
+
291,
|
| 585 |
+
743,
|
| 586 |
+
15,
|
| 587 |
+
837,
|
| 588 |
+
267,
|
| 589 |
+
403,
|
| 590 |
+
563,
|
| 591 |
+
194,
|
| 592 |
+
135,
|
| 593 |
+
469,
|
| 594 |
+
296,
|
| 595 |
+
43,
|
| 596 |
+
59,
|
| 597 |
+
966,
|
| 598 |
+
528,
|
| 599 |
+
135,
|
| 600 |
+
187,
|
| 601 |
+
635,
|
| 602 |
+
376,
|
| 603 |
+
421,
|
| 604 |
+
605,
|
| 605 |
+
929,
|
| 606 |
+
161,
|
| 607 |
+
243,
|
| 608 |
+
212,
|
| 609 |
+
852,
|
| 610 |
+
661,
|
| 611 |
+
92,
|
| 612 |
+
844,
|
| 613 |
+
902,
|
| 614 |
+
28,
|
| 615 |
+
930,
|
| 616 |
+
766,
|
| 617 |
+
352,
|
| 618 |
+
324,
|
| 619 |
+
104,
|
| 620 |
+
403,
|
| 621 |
+
755,
|
| 622 |
+
27,
|
| 623 |
+
299,
|
| 624 |
+
114,
|
| 625 |
+
480,
|
| 626 |
+
958
|
| 627 |
+
]
|
| 628 |
+
],
|
| 629 |
+
"output": 22
|
| 630 |
+
},
|
| 631 |
+
{
|
| 632 |
+
"input": [
|
| 633 |
+
[
|
| 634 |
+
287,
|
| 635 |
+
961,
|
| 636 |
+
506,
|
| 637 |
+
125,
|
| 638 |
+
140,
|
| 639 |
+
979,
|
| 640 |
+
604,
|
| 641 |
+
894,
|
| 642 |
+
907,
|
| 643 |
+
555,
|
| 644 |
+
757,
|
| 645 |
+
810,
|
| 646 |
+
385,
|
| 647 |
+
945,
|
| 648 |
+
61,
|
| 649 |
+
154,
|
| 650 |
+
725,
|
| 651 |
+
153,
|
| 652 |
+
921,
|
| 653 |
+
275,
|
| 654 |
+
787,
|
| 655 |
+
36,
|
| 656 |
+
758,
|
| 657 |
+
517,
|
| 658 |
+
147,
|
| 659 |
+
109,
|
| 660 |
+
678,
|
| 661 |
+
401
|
| 662 |
+
],
|
| 663 |
+
[
|
| 664 |
+
328,
|
| 665 |
+
688,
|
| 666 |
+
564,
|
| 667 |
+
547,
|
| 668 |
+
627,
|
| 669 |
+
951,
|
| 670 |
+
63,
|
| 671 |
+
598,
|
| 672 |
+
455,
|
| 673 |
+
590,
|
| 674 |
+
417,
|
| 675 |
+
577,
|
| 676 |
+
712,
|
| 677 |
+
65,
|
| 678 |
+
449,
|
| 679 |
+
695,
|
| 680 |
+
672,
|
| 681 |
+
943,
|
| 682 |
+
120,
|
| 683 |
+
854,
|
| 684 |
+
911,
|
| 685 |
+
781,
|
| 686 |
+
575,
|
| 687 |
+
189,
|
| 688 |
+
616,
|
| 689 |
+
491,
|
| 690 |
+
76,
|
| 691 |
+
341
|
| 692 |
+
]
|
| 693 |
+
],
|
| 694 |
+
"output": 7
|
| 695 |
+
},
|
| 696 |
+
{
|
| 697 |
+
"input": [
|
| 698 |
+
[
|
| 699 |
+
917,
|
| 700 |
+
76,
|
| 701 |
+
164,
|
| 702 |
+
865,
|
| 703 |
+
176,
|
| 704 |
+
616,
|
| 705 |
+
762
|
| 706 |
+
],
|
| 707 |
+
[
|
| 708 |
+
302,
|
| 709 |
+
83,
|
| 710 |
+
110,
|
| 711 |
+
124,
|
| 712 |
+
484,
|
| 713 |
+
733,
|
| 714 |
+
580
|
| 715 |
+
]
|
| 716 |
+
],
|
| 717 |
+
"output": 4
|
| 718 |
+
},
|
| 719 |
+
{
|
| 720 |
+
"input": [
|
| 721 |
+
[
|
| 722 |
+
246,
|
| 723 |
+
601,
|
| 724 |
+
986,
|
| 725 |
+
554,
|
| 726 |
+
800,
|
| 727 |
+
782,
|
| 728 |
+
872,
|
| 729 |
+
94,
|
| 730 |
+
654,
|
| 731 |
+
401,
|
| 732 |
+
714,
|
| 733 |
+
573,
|
| 734 |
+
610,
|
| 735 |
+
60,
|
| 736 |
+
974,
|
| 737 |
+
934,
|
| 738 |
+
32,
|
| 739 |
+
525,
|
| 740 |
+
124,
|
| 741 |
+
447,
|
| 742 |
+
381,
|
| 743 |
+
651,
|
| 744 |
+
860,
|
| 745 |
+
67,
|
| 746 |
+
892,
|
| 747 |
+
123,
|
| 748 |
+
314
|
| 749 |
+
],
|
| 750 |
+
[
|
| 751 |
+
613,
|
| 752 |
+
866,
|
| 753 |
+
771,
|
| 754 |
+
777,
|
| 755 |
+
788,
|
| 756 |
+
874,
|
| 757 |
+
912,
|
| 758 |
+
89,
|
| 759 |
+
32,
|
| 760 |
+
948,
|
| 761 |
+
61,
|
| 762 |
+
780,
|
| 763 |
+
582,
|
| 764 |
+
765,
|
| 765 |
+
598,
|
| 766 |
+
892,
|
| 767 |
+
661,
|
| 768 |
+
720,
|
| 769 |
+
347,
|
| 770 |
+
64,
|
| 771 |
+
695,
|
| 772 |
+
568,
|
| 773 |
+
606,
|
| 774 |
+
336,
|
| 775 |
+
505,
|
| 776 |
+
277,
|
| 777 |
+
470
|
| 778 |
+
]
|
| 779 |
+
],
|
| 780 |
+
"output": 6
|
| 781 |
+
},
|
| 782 |
+
{
|
| 783 |
+
"input": [
|
| 784 |
+
[
|
| 785 |
+
547,
|
| 786 |
+
508,
|
| 787 |
+
659,
|
| 788 |
+
603,
|
| 789 |
+
850,
|
| 790 |
+
549,
|
| 791 |
+
230,
|
| 792 |
+
61,
|
| 793 |
+
310,
|
| 794 |
+
905,
|
| 795 |
+
359,
|
| 796 |
+
247,
|
| 797 |
+
51,
|
| 798 |
+
668,
|
| 799 |
+
348,
|
| 800 |
+
701,
|
| 801 |
+
640,
|
| 802 |
+
810,
|
| 803 |
+
506,
|
| 804 |
+
304,
|
| 805 |
+
564,
|
| 806 |
+
864,
|
| 807 |
+
510,
|
| 808 |
+
118,
|
| 809 |
+
19,
|
| 810 |
+
775,
|
| 811 |
+
203,
|
| 812 |
+
162,
|
| 813 |
+
509,
|
| 814 |
+
197,
|
| 815 |
+
548,
|
| 816 |
+
764,
|
| 817 |
+
646,
|
| 818 |
+
281,
|
| 819 |
+
89,
|
| 820 |
+
562,
|
| 821 |
+
868,
|
| 822 |
+
841,
|
| 823 |
+
988,
|
| 824 |
+
240,
|
| 825 |
+
15,
|
| 826 |
+
641,
|
| 827 |
+
853,
|
| 828 |
+
595,
|
| 829 |
+
355,
|
| 830 |
+
544,
|
| 831 |
+
58,
|
| 832 |
+
34,
|
| 833 |
+
445
|
| 834 |
+
],
|
| 835 |
+
[
|
| 836 |
+
309,
|
| 837 |
+
734,
|
| 838 |
+
946,
|
| 839 |
+
832,
|
| 840 |
+
469,
|
| 841 |
+
609,
|
| 842 |
+
220,
|
| 843 |
+
296,
|
| 844 |
+
154,
|
| 845 |
+
309,
|
| 846 |
+
106,
|
| 847 |
+
301,
|
| 848 |
+
449,
|
| 849 |
+
187,
|
| 850 |
+
863,
|
| 851 |
+
290,
|
| 852 |
+
845,
|
| 853 |
+
958,
|
| 854 |
+
66,
|
| 855 |
+
214,
|
| 856 |
+
380,
|
| 857 |
+
267,
|
| 858 |
+
714,
|
| 859 |
+
332,
|
| 860 |
+
568,
|
| 861 |
+
349,
|
| 862 |
+
815,
|
| 863 |
+
889,
|
| 864 |
+
755,
|
| 865 |
+
307,
|
| 866 |
+
892,
|
| 867 |
+
390,
|
| 868 |
+
663,
|
| 869 |
+
513,
|
| 870 |
+
453,
|
| 871 |
+
777,
|
| 872 |
+
137,
|
| 873 |
+
697,
|
| 874 |
+
59,
|
| 875 |
+
404,
|
| 876 |
+
708,
|
| 877 |
+
901,
|
| 878 |
+
312,
|
| 879 |
+
301,
|
| 880 |
+
197,
|
| 881 |
+
717,
|
| 882 |
+
793,
|
| 883 |
+
388,
|
| 884 |
+
907
|
| 885 |
+
]
|
| 886 |
+
],
|
| 887 |
+
"output": 7
|
| 888 |
+
},
|
| 889 |
+
{
|
| 890 |
+
"input": [
|
| 891 |
+
[
|
| 892 |
+
106,
|
| 893 |
+
115,
|
| 894 |
+
429,
|
| 895 |
+
450,
|
| 896 |
+
299,
|
| 897 |
+
889,
|
| 898 |
+
614,
|
| 899 |
+
520,
|
| 900 |
+
262,
|
| 901 |
+
541,
|
| 902 |
+
297,
|
| 903 |
+
714,
|
| 904 |
+
409,
|
| 905 |
+
718,
|
| 906 |
+
257,
|
| 907 |
+
228,
|
| 908 |
+
188,
|
| 909 |
+
828,
|
| 910 |
+
18,
|
| 911 |
+
496,
|
| 912 |
+
322,
|
| 913 |
+
968,
|
| 914 |
+
45,
|
| 915 |
+
701,
|
| 916 |
+
1,
|
| 917 |
+
140,
|
| 918 |
+
861,
|
| 919 |
+
263,
|
| 920 |
+
651,
|
| 921 |
+
768,
|
| 922 |
+
40,
|
| 923 |
+
362,
|
| 924 |
+
886,
|
| 925 |
+
24,
|
| 926 |
+
95,
|
| 927 |
+
741,
|
| 928 |
+
874,
|
| 929 |
+
846,
|
| 930 |
+
489,
|
| 931 |
+
908,
|
| 932 |
+
234,
|
| 933 |
+
499,
|
| 934 |
+
463,
|
| 935 |
+
986,
|
| 936 |
+
352,
|
| 937 |
+
784,
|
| 938 |
+
274,
|
| 939 |
+
883,
|
| 940 |
+
556,
|
| 941 |
+
151,
|
| 942 |
+
843
|
| 943 |
+
],
|
| 944 |
+
[
|
| 945 |
+
451,
|
| 946 |
+
316,
|
| 947 |
+
232,
|
| 948 |
+
346,
|
| 949 |
+
359,
|
| 950 |
+
766,
|
| 951 |
+
248,
|
| 952 |
+
973,
|
| 953 |
+
192,
|
| 954 |
+
984,
|
| 955 |
+
294,
|
| 956 |
+
648,
|
| 957 |
+
508,
|
| 958 |
+
680,
|
| 959 |
+
190,
|
| 960 |
+
319,
|
| 961 |
+
239,
|
| 962 |
+
516,
|
| 963 |
+
404,
|
| 964 |
+
2,
|
| 965 |
+
108,
|
| 966 |
+
284,
|
| 967 |
+
130,
|
| 968 |
+
756,
|
| 969 |
+
178,
|
| 970 |
+
398,
|
| 971 |
+
674,
|
| 972 |
+
453,
|
| 973 |
+
999,
|
| 974 |
+
289,
|
| 975 |
+
724,
|
| 976 |
+
208,
|
| 977 |
+
766,
|
| 978 |
+
701,
|
| 979 |
+
722,
|
| 980 |
+
806,
|
| 981 |
+
193,
|
| 982 |
+
127,
|
| 983 |
+
114,
|
| 984 |
+
111,
|
| 985 |
+
541,
|
| 986 |
+
715,
|
| 987 |
+
879,
|
| 988 |
+
942,
|
| 989 |
+
740,
|
| 990 |
+
386,
|
| 991 |
+
742,
|
| 992 |
+
670,
|
| 993 |
+
208,
|
| 994 |
+
571,
|
| 995 |
+
482
|
| 996 |
+
]
|
| 997 |
+
],
|
| 998 |
+
"output": 9
|
| 999 |
+
},
|
| 1000 |
+
{
|
| 1001 |
+
"input": [
|
| 1002 |
+
[
|
| 1003 |
+
279,
|
| 1004 |
+
316,
|
| 1005 |
+
333,
|
| 1006 |
+
913,
|
| 1007 |
+
439,
|
| 1008 |
+
315,
|
| 1009 |
+
467,
|
| 1010 |
+
271,
|
| 1011 |
+
619,
|
| 1012 |
+
380,
|
| 1013 |
+
527,
|
| 1014 |
+
735,
|
| 1015 |
+
898,
|
| 1016 |
+
235,
|
| 1017 |
+
850,
|
| 1018 |
+
667
|
| 1019 |
+
],
|
| 1020 |
+
[
|
| 1021 |
+
215,
|
| 1022 |
+
727,
|
| 1023 |
+
310,
|
| 1024 |
+
334,
|
| 1025 |
+
228,
|
| 1026 |
+
834,
|
| 1027 |
+
670,
|
| 1028 |
+
633,
|
| 1029 |
+
139,
|
| 1030 |
+
745,
|
| 1031 |
+
630,
|
| 1032 |
+
73,
|
| 1033 |
+
197,
|
| 1034 |
+
249,
|
| 1035 |
+
866,
|
| 1036 |
+
803
|
| 1037 |
+
]
|
| 1038 |
+
],
|
| 1039 |
+
"output": 5
|
| 1040 |
+
}
|
| 1041 |
+
],
|
| 1042 |
+
"haskell_template": "numOfUnplacedFruits :: [Int] -> [Int] -> Int\nnumOfUnplacedFruits fruits baskets ",
|
| 1043 |
+
"ocaml_template": "let numOfUnplacedFruits (fruits: int list) (baskets: int list) : int = ",
|
| 1044 |
+
"scala_template": "def numOfUnplacedFruits(fruits: List[Int],baskets: List[Int]): Int = { \n \n}",
|
| 1045 |
+
"java_template": "class Solution {\n public int numOfUnplacedFruits(int[] fruits, int[] baskets) {\n \n }\n}",
|
| 1046 |
+
"python_template": "class Solution(object):\n def numOfUnplacedFruits(self, fruits, baskets):\n \"\"\"\n :type fruits: List[int]\n :type baskets: List[int]\n :rtype: int\n \"\"\"\n "
|
| 1047 |
+
}
|
fruits_into_baskets_ii/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 1 (numOfUnplacedFruits [4;2;5] [3;5;4])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 0 (numOfUnplacedFruits [3;6;1] [6;4;7])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 16 (numOfUnplacedFruits [903; 138; 352; 970; 513; 942; 730; 780; 235; 391; 839; 225; 143; 988; 817; 576; 130; 910; 938; 28; 572; 400; 583; 72; 393; 962; 322; 515; 913; 122; 529; 637; 647; 887; 841; 257; 843; 786; 120; 508; 779; 252; 77; 567; 396; 1000; 151; 639; 634; 641; 479; 222; 975; 309; 652; 283; 328; 980; 28; 596; 73; 753; 785; 598; 64; 435; 627; 603; 119; 408; 795; 183; 76; 83; 274; 354; 789; 660; 664; 9; 349; 774; 592; 654; 723; 282; 741; 946; 420; 53; 950] [602; 189; 806; 622; 620; 991; 466; 388; 135; 605; 166; 967; 185; 35; 751; 103; 638; 255; 785; 185; 150; 260; 664; 294; 863; 785; 684; 395; 22; 339; 667; 816; 877; 65; 396; 901; 847; 974; 722; 315; 962; 577; 938; 160; 896; 548; 542; 852; 34; 20; 531; 404; 248; 622; 126; 451; 543; 814; 631; 974; 423; 110; 955; 554; 175; 955; 577; 298; 186; 894; 145; 250; 659; 457; 767; 25; 447; 658; 957; 402; 217; 557; 150; 598; 636; 284; 385; 414; 924; 300; 214])
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 7 (numOfUnplacedFruits [411; 645; 458; 749; 266; 472; 819; 468; 188; 631; 451; 513; 368; 790; 35; 677; 988; 396; 770; 269; 917; 46; 506; 582; 682; 904; 502; 182; 211; 160; 218; 548; 403; 18; 961; 351] [668; 1000; 676; 24; 389; 903; 592; 896; 30; 343; 765; 537; 241; 850; 579; 566; 350; 757; 340; 88; 814; 233; 215; 371; 916; 836; 245; 940; 131; 936; 30; 627; 113; 444; 129; 111])
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 9 (numOfUnplacedFruits [478; 114; 219; 666; 231; 829; 926; 125; 35; 578; 486; 207; 647; 154; 57; 717; 210; 591; 347; 263; 329; 622; 565; 965; 732; 86; 517; 972; 791; 614; 488; 194; 42; 395; 344; 832; 192; 575; 190; 675; 549; 418; 426; 637; 660; 337; 485; 351; 629; 757; 909; 963; 129; 139; 708; 504; 192; 129; 306; 376; 640; 517; 642; 598; 852] [610; 739; 185; 884; 715; 976; 950; 64; 780; 83; 179; 397; 911; 683; 560; 723; 946; 161; 611; 524; 305; 470; 70; 916; 646; 577; 161; 402; 491; 322; 242; 466; 920; 151; 342; 545; 570; 685; 823; 245; 152; 332; 180; 806; 139; 418; 206; 377; 389; 256; 852; 691; 225; 823; 69; 873; 409; 514; 307; 632; 612; 502; 643; 544; 934])
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 22 (numOfUnplacedFruits [855; 426; 606; 929; 591; 33; 138; 80; 985; 56; 812; 901; 795; 995; 870; 983; 420; 106; 222; 186; 418; 32; 901; 91; 429; 195; 230; 875; 806; 419; 54; 859; 746; 681; 742; 992; 515; 342; 712; 222; 278; 77; 558; 529; 821; 176; 750; 372; 635; 370; 532; 237; 970; 392; 629; 588; 713; 851; 639; 90; 665; 622; 561; 93; 623; 364; 36; 9; 783; 607; 642; 983; 347; 490; 208; 546; 520; 99; 465; 31; 218; 431; 376; 771; 530; 344; 937; 565; 457; 643; 471; 904; 545; 213; 153] [215; 175; 405; 333; 903; 845; 42; 873; 746; 922; 572; 814; 259; 309; 611; 331; 767; 111; 377; 736; 733; 599; 29; 21; 801; 461; 51; 159; 445; 421; 278; 593; 69; 258; 60; 772; 393; 73; 685; 970; 890; 175; 938; 220; 516; 703; 891; 991; 883; 166; 303; 830; 291; 743; 15; 837; 267; 403; 563; 194; 135; 469; 296; 43; 59; 966; 528; 135; 187; 635; 376; 421; 605; 929; 161; 243; 212; 852; 661; 92; 844; 902; 28; 930; 766; 352; 324; 104; 403; 755; 27; 299; 114; 480; 958])
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 7 (numOfUnplacedFruits [287; 961; 506; 125; 140; 979; 604; 894; 907; 555; 757; 810; 385; 945; 61; 154; 725; 153; 921; 275; 787; 36; 758; 517; 147; 109; 678; 401] [328; 688; 564; 547; 627; 951; 63; 598; 455; 590; 417; 577; 712; 65; 449; 695; 672; 943; 120; 854; 911; 781; 575; 189; 616; 491; 76; 341])
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 4 (numOfUnplacedFruits [917; 76; 164; 865; 176; 616; 762] [302; 83; 110; 124; 484; 733; 580])
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 6 (numOfUnplacedFruits [246; 601; 986; 554; 800; 782; 872; 94; 654; 401; 714; 573; 610; 60; 974; 934; 32; 525; 124; 447; 381; 651; 860; 67; 892; 123; 314] [613; 866; 771; 777; 788; 874; 912; 89; 32; 948; 61; 780; 582; 765; 598; 892; 661; 720; 347; 64; 695; 568; 606; 336; 505; 277; 470])
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 7 (numOfUnplacedFruits [547; 508; 659; 603; 850; 549; 230; 61; 310; 905; 359; 247; 51; 668; 348; 701; 640; 810; 506; 304; 564; 864; 510; 118; 19; 775; 203; 162; 509; 197; 548; 764; 646; 281; 89; 562; 868; 841; 988; 240; 15; 641; 853; 595; 355; 544; 58; 34; 445] [309; 734; 946; 832; 469; 609; 220; 296; 154; 309; 106; 301; 449; 187; 863; 290; 845; 958; 66; 214; 380; 267; 714; 332; 568; 349; 815; 889; 755; 307; 892; 390; 663; 513; 453; 777; 137; 697; 59; 404; 708; 901; 312; 301; 197; 717; 793; 388; 907])
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for numOfUnplacedFruits" >::: [
|
| 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
|
fruits_into_baskets_ii/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numOfUnplacedFruits(List(4,2,5),List(3,5,4)), 1)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numOfUnplacedFruits(List(3,6,1),List(6,4,7)), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.numOfUnplacedFruits(List(903, 138, 352, 970, 513, 942, 730, 780, 235, 391, 839, 225, 143, 988, 817, 576, 130, 910, 938, 28, 572, 400, 583, 72, 393, 962, 322, 515, 913, 122, 529, 637, 647, 887, 841, 257, 843, 786, 120, 508, 779, 252, 77, 567, 396, 1000, 151, 639, 634, 641, 479, 222, 975, 309, 652, 283, 328, 980, 28, 596, 73, 753, 785, 598, 64, 435, 627, 603, 119, 408, 795, 183, 76, 83, 274, 354, 789, 660, 664, 9, 349, 774, 592, 654, 723, 282, 741, 946, 420, 53, 950),List(602, 189, 806, 622, 620, 991, 466, 388, 135, 605, 166, 967, 185, 35, 751, 103, 638, 255, 785, 185, 150, 260, 664, 294, 863, 785, 684, 395, 22, 339, 667, 816, 877, 65, 396, 901, 847, 974, 722, 315, 962, 577, 938, 160, 896, 548, 542, 852, 34, 20, 531, 404, 248, 622, 126, 451, 543, 814, 631, 974, 423, 110, 955, 554, 175, 955, 577, 298, 186, 894, 145, 250, 659, 457, 767, 25, 447, 658, 957, 402, 217, 557, 150, 598, 636, 284, 385, 414, 924, 300, 214)), 16)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.numOfUnplacedFruits(List(411, 645, 458, 749, 266, 472, 819, 468, 188, 631, 451, 513, 368, 790, 35, 677, 988, 396, 770, 269, 917, 46, 506, 582, 682, 904, 502, 182, 211, 160, 218, 548, 403, 18, 961, 351),List(668, 1000, 676, 24, 389, 903, 592, 896, 30, 343, 765, 537, 241, 850, 579, 566, 350, 757, 340, 88, 814, 233, 215, 371, 916, 836, 245, 940, 131, 936, 30, 627, 113, 444, 129, 111)), 7)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.numOfUnplacedFruits(List(478, 114, 219, 666, 231, 829, 926, 125, 35, 578, 486, 207, 647, 154, 57, 717, 210, 591, 347, 263, 329, 622, 565, 965, 732, 86, 517, 972, 791, 614, 488, 194, 42, 395, 344, 832, 192, 575, 190, 675, 549, 418, 426, 637, 660, 337, 485, 351, 629, 757, 909, 963, 129, 139, 708, 504, 192, 129, 306, 376, 640, 517, 642, 598, 852),List(610, 739, 185, 884, 715, 976, 950, 64, 780, 83, 179, 397, 911, 683, 560, 723, 946, 161, 611, 524, 305, 470, 70, 916, 646, 577, 161, 402, 491, 322, 242, 466, 920, 151, 342, 545, 570, 685, 823, 245, 152, 332, 180, 806, 139, 418, 206, 377, 389, 256, 852, 691, 225, 823, 69, 873, 409, 514, 307, 632, 612, 502, 643, 544, 934)), 9)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.numOfUnplacedFruits(List(855, 426, 606, 929, 591, 33, 138, 80, 985, 56, 812, 901, 795, 995, 870, 983, 420, 106, 222, 186, 418, 32, 901, 91, 429, 195, 230, 875, 806, 419, 54, 859, 746, 681, 742, 992, 515, 342, 712, 222, 278, 77, 558, 529, 821, 176, 750, 372, 635, 370, 532, 237, 970, 392, 629, 588, 713, 851, 639, 90, 665, 622, 561, 93, 623, 364, 36, 9, 783, 607, 642, 983, 347, 490, 208, 546, 520, 99, 465, 31, 218, 431, 376, 771, 530, 344, 937, 565, 457, 643, 471, 904, 545, 213, 153),List(215, 175, 405, 333, 903, 845, 42, 873, 746, 922, 572, 814, 259, 309, 611, 331, 767, 111, 377, 736, 733, 599, 29, 21, 801, 461, 51, 159, 445, 421, 278, 593, 69, 258, 60, 772, 393, 73, 685, 970, 890, 175, 938, 220, 516, 703, 891, 991, 883, 166, 303, 830, 291, 743, 15, 837, 267, 403, 563, 194, 135, 469, 296, 43, 59, 966, 528, 135, 187, 635, 376, 421, 605, 929, 161, 243, 212, 852, 661, 92, 844, 902, 28, 930, 766, 352, 324, 104, 403, 755, 27, 299, 114, 480, 958)), 22)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.numOfUnplacedFruits(List(287, 961, 506, 125, 140, 979, 604, 894, 907, 555, 757, 810, 385, 945, 61, 154, 725, 153, 921, 275, 787, 36, 758, 517, 147, 109, 678, 401),List(328, 688, 564, 547, 627, 951, 63, 598, 455, 590, 417, 577, 712, 65, 449, 695, 672, 943, 120, 854, 911, 781, 575, 189, 616, 491, 76, 341)), 7)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.numOfUnplacedFruits(List(917, 76, 164, 865, 176, 616, 762),List(302, 83, 110, 124, 484, 733, 580)), 4)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.numOfUnplacedFruits(List(246, 601, 986, 554, 800, 782, 872, 94, 654, 401, 714, 573, 610, 60, 974, 934, 32, 525, 124, 447, 381, 651, 860, 67, 892, 123, 314),List(613, 866, 771, 777, 788, 874, 912, 89, 32, 948, 61, 780, 582, 765, 598, 892, 661, 720, 347, 64, 695, 568, 606, 336, 505, 277, 470)), 6)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.numOfUnplacedFruits(List(547, 508, 659, 603, 850, 549, 230, 61, 310, 905, 359, 247, 51, 668, 348, 701, 640, 810, 506, 304, 564, 864, 510, 118, 19, 775, 203, 162, 509, 197, 548, 764, 646, 281, 89, 562, 868, 841, 988, 240, 15, 641, 853, 595, 355, 544, 58, 34, 445),List(309, 734, 946, 832, 469, 609, 220, 296, 154, 309, 106, 301, 449, 187, 863, 290, 845, 958, 66, 214, 380, 267, 714, 332, 568, 349, 815, 889, 755, 307, 892, 390, 663, 513, 453, 777, 137, 697, 59, 404, 708, 901, 312, 301, 197, 717, 793, 388, 907)), 7)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
fruits_into_baskets_iii/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:083a28ebc47ee73e9a72fda1ec846b1a07bc1b1d4f93a810d4ce9f0027f7d711
|
| 3 |
+
size 15288288
|
fruits_into_baskets_iii/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(1, numOfUnplacedFruits(new ArrayList<>(Arrays.asList(4,2,5)), new ArrayList<>(Arrays.asList(3,5,4))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(0, numOfUnplacedFruits(new ArrayList<>(Arrays.asList(3,6,1)), new ArrayList<>(Arrays.asList(6,4,7))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
fruits_into_baskets_iii/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:700e247fd94a17826a75f7568c8766ecc9bd371a642f5d22147c12495c66ed1f
|
| 3 |
+
size 21685725
|
fruits_into_baskets_iii/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
fruits_into_baskets_iii/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
furthest_point_from_origin/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
furthestDistanceFromOrigin :: String -> Int
|
| 7 |
+
furthestDistanceFromOrigin moves = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"L_RL__R \")," 3 (furthestDistanceFromOrigin "L_RL__R"))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"_R__LL_ \")," 5 (furthestDistanceFromOrigin "_R__LL_"))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"_______ \")," 7 (furthestDistanceFromOrigin "_______"))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"__ \")," 2 (furthestDistanceFromOrigin "__"))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"L_RRLRRL_LR__LR_R__R__L \")," 11 (furthestDistanceFromOrigin "L_RRLRRL_LR__LR_R__R__L"))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"_LL_L_R_RLLL__RLL_RLL_R___LRLL_ \")," 19 (furthestDistanceFromOrigin "_LL_L_R_RLLL__RLL_RLL_R___LRLL_"))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"_LRLRL_LLL_RLLL____RRR__RLRRLL_L_LR_LLRLLL_RRR__R \")," 19 (furthestDistanceFromOrigin "_LRLRL_LLL_RLLL____RRR__RLRRLL_L_LR_LLRLLL_RRR__R"))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (furthestDistanceFromOrigin \"RRR_LLLRRRR_L_LRRL_L__ \")," 8 (furthestDistanceFromOrigin "RRR_LLLRRRR_L_LRRL_L__"))
|
| 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
|
furthest_point_from_origin/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(3, furthestDistanceFromOrigin("L_RL__R"));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(5, furthestDistanceFromOrigin("_R__LL_"));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(7, furthestDistanceFromOrigin("_______"));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
furthest_point_from_origin/meta.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3019,
|
| 3 |
+
"name": "furthest_point_from_origin",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/furthest-point-from-origin/",
|
| 6 |
+
"date": "2023-08-20 00:00:00",
|
| 7 |
+
"task_description": "You are given a string `moves` of length `n` consisting only of characters `'L'`, `'R'`, and `'_'`. The string represents your movement on a number line starting from the origin `0`. In the `ith` move, you can choose one of the following directions: move to the left if `moves[i] = 'L'` or `moves[i] = '_'` move to the right if `moves[i] = 'R'` or `moves[i] = '_'` Return _the **distance from the origin** of the **furthest** point you can get to after _`n`_ moves_. **Example 1:** ``` **Input:** moves = \"L_RL__R\" **Output:** 3 **Explanation:** The furthest point we can reach from the origin 0 is point -3 through the following sequence of moves \"LLRLLLR\". ``` **Example 2:** ``` **Input:** moves = \"_R__LL_\" **Output:** 5 **Explanation:** The furthest point we can reach from the origin 0 is point -5 through the following sequence of moves \"LRLLLLL\". ``` **Example 3:** ``` **Input:** moves = \"_______\" **Output:** 7 **Explanation:** The furthest point we can reach from the origin 0 is point 7 through the following sequence of moves \"RRRRRRR\". ``` **Constraints:** `1 <= moves.length == n <= 50` `moves` consists only of characters `'L'`, `'R'` and `'_'`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "moves = \"L_RL__R\"",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "moves = \"_R__LL_\"",
|
| 17 |
+
"output": "5 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "moves = \"_______\"",
|
| 22 |
+
"output": "7 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": "__",
|
| 28 |
+
"output": 2
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"input": "L_RRLRRL_LR__LR_R__R__L",
|
| 32 |
+
"output": 11
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": "_LL_L_R_RLLL__RLL_RLL_R___LRLL_",
|
| 36 |
+
"output": 19
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": "_LRLRL_LLL_RLLL____RRR__RLRRLL_L_LR_LLRLLL_RRR__R",
|
| 40 |
+
"output": 19
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": "RRR_LLLRRRR_L_LRRL_L__",
|
| 44 |
+
"output": 8
|
| 45 |
+
}
|
| 46 |
+
],
|
| 47 |
+
"haskell_template": "furthestDistanceFromOrigin :: String -> Int\nfurthestDistanceFromOrigin moves ",
|
| 48 |
+
"ocaml_template": "let furthestDistanceFromOrigin (moves: string) : int = ",
|
| 49 |
+
"scala_template": "def furthestDistanceFromOrigin(moves: String): Int = { \n \n}",
|
| 50 |
+
"java_template": "class Solution {\n public int furthestDistanceFromOrigin(String moves) {\n \n }\n}",
|
| 51 |
+
"python_template": "class Solution(object):\n def furthestDistanceFromOrigin(self, moves):\n \"\"\"\n :type moves: str\n :rtype: int\n \"\"\"\n "
|
| 52 |
+
}
|
furthest_point_from_origin/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let furthestDistanceFromOrigin (moves: string) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 3 (furthestDistanceFromOrigin "L_RL__R")
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 5 (furthestDistanceFromOrigin "_R__LL_")
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 7 (furthestDistanceFromOrigin "_______")
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 7 (furthestDistanceFromOrigin "__")
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 7 (furthestDistanceFromOrigin "L_RRLRRL_LR__LR_R__R__L")
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 7 (furthestDistanceFromOrigin "_LL_L_R_RLLL__RLL_RLL_R___LRLL_")
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 7 (furthestDistanceFromOrigin "_LRLRL_LLL_RLLL____RRR__RLRRLL_L_LR_LLRLLL_RRR__R")
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal 7 (furthestDistanceFromOrigin "RRR_LLLRRRR_L_LRRL_L__")
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
(* Grouping test cases *)
|
| 30 |
+
let suite = "Test Suite for furthestDistanceFromOrigin" >::: [
|
| 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
|
furthest_point_from_origin/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.furthestDistanceFromOrigin("L_RL__R"), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.furthestDistanceFromOrigin("_R__LL_"), 5)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.furthestDistanceFromOrigin("_______"), 7)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.furthestDistanceFromOrigin(",_,_,"), 2)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.furthestDistanceFromOrigin(",L,_,R,R,L,R,R,L,_,L,R,_,_,L,R,_,R,_,_,R,_,_,L,"), 11)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.furthestDistanceFromOrigin(",_,L,L,_,L,_,R,_,R,L,L,L,_,_,R,L,L,_,R,L,L,_,R,_,_,_,L,R,L,L,_,"), 19)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.furthestDistanceFromOrigin(",_,L,R,L,R,L,_,L,L,L,_,R,L,L,L,_,_,_,_,R,R,R,_,_,R,L,R,R,L,L,_,L,_,L,R,_,L,L,R,L,L,L,_,R,R,R,_,_,R,"), 19)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.furthestDistanceFromOrigin(",R,R,R,_,L,L,L,R,R,R,R,_,L,_,L,R,R,L,_,L,_,_,"), 8)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
greatest_common_divisor_traversal/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
greatest_common_divisor_traversal/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(true, canTraverseAllPairs(Arrays.asList(2,3,6)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(false, canTraverseAllPairs(Arrays.asList(3,9,5)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(true, canTraverseAllPairs(Arrays.asList(4,3,12,8)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
greatest_common_divisor_traversal/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
greatest_common_divisor_traversal/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
greatest_common_divisor_traversal/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
groups_of_strings/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
groups_of_strings/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 (groupStrings [ \"a \", \"b \", \"ab \", \"cde \"])," [2,3] (groupStrings ["a","b","ab","cde"]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (groupStrings [ \"a \", \"ab \", \"abc \"])," [1,3] (groupStrings ["a","ab","abc"]))
|
| 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
|
groups_of_strings/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(new ArrayList<>(Arrays.asList(2,3)), groupStrings(new ArrayList<>(Arrays.asList("a","b","ab","cde"))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(1,3)), groupStrings(new ArrayList<>(Arrays.asList("a","ab","abc"))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
groups_of_strings/meta.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2276,
|
| 3 |
+
"name": "groups_of_strings",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/groups-of-strings/",
|
| 6 |
+
"date": "1642896000000",
|
| 7 |
+
"task_description": "You are given a **0-indexed** array of strings `words`. Each string consists of **lowercase English letters** only. No letter occurs more than once in any string of `words`. Two strings `s1` and `s2` are said to be **connected** if the set of letters of `s2` can be obtained from the set of letters of `s1` by any **one** of the following operations: Adding exactly one letter to the set of the letters of `s1`. Deleting exactly one letter from the set of the letters of `s1`. Replacing exactly one letter from the set of the letters of `s1` with any letter, **including** itself. The array `words` can be divided into one or more non-intersecting **groups**. A string belongs to a group if any **one** of the following is true: It is connected to **at least one** other string of the group. It is the **only** string present in the group. Note that the strings in `words` should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique. Return _an array_ `ans` _of size_ `2` _where:_ `ans[0]` _is the **maximum number** of groups_ `words` _can be divided into, and_ `ans[1]` _is the **size of the largest** group_. **Example 1:** ``` **Input:** words = [\"a\",\"b\",\"ab\",\"cde\"] **Output:** [2,3] **Explanation:** - words[0] can be used to obtain words[1] (by replacing 'a' with 'b'), and words[2] (by adding 'b'). So words[0] is connected to words[1] and words[2]. - words[1] can be used to obtain words[0] (by replacing 'b' with 'a'), and words[2] (by adding 'a'). So words[1] is connected to words[0] and words[2]. - words[2] can be used to obtain words[0] (by deleting 'b'), and words[1] (by deleting 'a'). So words[2] is connected to words[0] and words[1]. - words[3] is not connected to any string in words. Thus, words can be divided into 2 groups [\"a\",\"b\",\"ab\"] and [\"cde\"]. The size of the largest group is 3. ``` **Example 2:** ``` **Input:** words = [\"a\",\"ab\",\"abc\"] **Output:** [1,3] **Explanation:** - words[0] is connected to words[1]. - words[1] is connected to words[0] and words[2]. - words[2] is connected to words[1]. Since all strings are connected to each other, they should be grouped together. Thus, the size of the largest group is 3. ``` **Constraints:** `1 <= words.length <= 2 * 104` `1 <= words[i].length <= 26` `words[i]` consists of lowercase English letters only. No letter occurs more than once in `words[i]`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "words = [\"a\",\"b\",\"ab\",\"cde\"]",
|
| 12 |
+
"output": "[2,3] "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "words = [\"a\",\"ab\",\"abc\"]",
|
| 17 |
+
"output": "[1,3] "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [],
|
| 21 |
+
"haskell_template": "groupStrings :: [String] -> [Int]\ngroupStrings words ",
|
| 22 |
+
"ocaml_template": "let groupStrings (words: string list) : int list = ",
|
| 23 |
+
"scala_template": "def groupStrings(words: List[String]): List[Int] = { \n \n}",
|
| 24 |
+
"java_template": "public static List<Integer> groupStrings(List<String> words) {\n\n}",
|
| 25 |
+
"python_template": "class Solution(object):\n def groupStrings(self, words):\n \"\"\"\n :type words: List[str]\n :rtype: List[int]\n \"\"\"\n "
|
| 26 |
+
}
|
groups_of_strings/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal [2;3] (groupStrings ["a";"b";"ab";"cde"])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal [1;3] (groupStrings ["a";"ab";"abc"])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for groupStrings" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
groups_of_strings/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.groupStrings(List("a","b","ab","cde")), List(2,3))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.groupStrings(List("a","ab","abc")), List(1,3))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
handling_sum_queries_after_update/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
handling_sum_queries_after_update/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 (handleQuery [1,0,1] [0,0,0] [[1,1,1],[2,1,0],[3,0,0]])," [3] (handleQuery [1,0,1] [0,0,0] [[1,1,1],[2,1,0],[3,0,0]]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (handleQuery [1] [5] [[2,0,0],[3,0,0]])," [5] (handleQuery [1] [5] [[2,0,0],[3,0,0]]))
|
| 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
|
handling_sum_queries_after_update/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(new ArrayList<>(Arrays.asList(3)), handleQuery(new ArrayList<>(Arrays.asList(1,0,1)), new ArrayList<>(Arrays.asList(0,0,0)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,1,1)),new ArrayList<>(Arrays.asList(2,1,0)),new ArrayList<>(Arrays.asList(3,0,0))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(5)), handleQuery(new ArrayList<>(Arrays.asList(1)), new ArrayList<>(Arrays.asList(5)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(2,0,0)),new ArrayList<>(Arrays.asList(3,0,0))))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
handling_sum_queries_after_update/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40535ed431efa8265b5a4dc4bc606803e9d2d3348b1ed4036feeb35770c2b7d3
|
| 3 |
+
size 87650065
|
handling_sum_queries_after_update/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal [3] (handleQuery [1;0;1] [0;0;0] [[1;1;1];[2;1;0];[3;0;0]])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal [5] (handleQuery [1] [5] [[2;0;0];[3;0;0]])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for handleQuery" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
handling_sum_queries_after_update/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.handleQuery(List(1,0,1),List(0,0,0),List(List(1,1,1),List(2,1,0),List(3,0,0))), List(3))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.handleQuery(List(1),List(5),List(List(2,0,0),List(3,0,0))), List(5))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
happy_students/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
happy_students/java_tests/Main.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(2, countWays(Arrays.asList(1,1)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(3, countWays(Arrays.asList(6,0,3,3,6,7,2,7)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|