TheRealSamuel/LeetCodeProblem
0564
1 2module Main = struct3 open OUnit24 5 (* Program start *)6 7 (* Program end *)8 9 (* Test cases *)10 11let test1 _ = assert_equal 1 (minimumSumSubarray [3; ( -2); 1; 4] 2 3)12 13let test2 _ = assert_equal (-1) (minimumSumSubarray [-2; 2; ( -3); 1] 2 3)14 15let test3 _ = assert_equal 3 (minimumSumSubarray [1; 2; 3; 4] 2 4)16 17let test4 _ = assert_equal 1236 (minimumSumSubarray [-484; ( -678); ( -161); 772; 485; 954; 849; ( -120); ( -381)] 9 9)18 19let test5 _ = assert_equal (-1) (minimumSumSubarray [500; 204; ( -946); 751; ( -938); ( -95); ( -751); ( -731); 323; 207; 412] 5 7)20 21let test6 _ = assert_equal (-1) (minimumSumSubarray [104; 328; ( -640); ( -399); ( -47)] 3 4)22 23let test7 _ = assert_equal 193 (minimumSumSubarray [604; ( -245); ( -778); 618; ( -603); 185; ( -844); 978; ( -477); 336; ( -834)] 7 11)24 25let test8 _ = assert_equal 12 (minimumSumSubarray [225; 122; ( -360); ( -26); 147; ( -688); 602; 749; ( -194); ( -122); 795; 835; ( -377); 125; ( -387); 60; ( -517); 256; ( -852); ( -744); 920; 582; ( -204); 34; 748; ( -459); 113; 97; ( -655); 786; ( -946); 187; ( -597); ( -818); ( -28); 523; ( -227); ( -424); 262; 788; 209; ( -492); 373; ( -258); 289; 987; 941; ( -515); ( -787); ( -215); 878; ( -652); 873; ( -214); 255; ( -237); ( -702); 879; 70; ( -718); ( -333)] 24 49)26 27let test9 _ = assert_equal 334 (minimumSumSubarray [-715; ( -35); 301; 182; 738; ( -819); 682; 627; 399; ( -431)] 7 9)28 29let test10 _ = assert_equal 98 (minimumSumSubarray [-737; ( -966); 129; ( -822); 447; 700; 317; 954; ( -551); 820; ( -436); ( -467); 26; 405; 38; 96; ( -671); 479; 842; 101; 852; 557; 795; ( -872); ( -451); ( -511); ( -253)] 5 7)30 31 32 (* Grouping test cases *)33 let suite = "Test Suite for minimumSumSubarray" >::: [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 suite50end51 