be8f1cce3a0f463240b62b24b9d4ef97b4400e560d24a55825db07a8bcbca50d
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +3 -0
- unique_3_digit_even_numbers/ocaml_tests/main.ml +48 -0
- unique_3_digit_even_numbers/scala_tests/MySuite.scala +40 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/.DS_Store +0 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/haskell_tests/Main.hs +27 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/java_tests/Main.java +25 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/meta.json +0 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/ocaml_tests/main.ml +29 -0
- using_a_robot_to_print_the_lexicographically_smallest_string/scala_tests/MySuite.scala +16 -0
- valid_word/haskell_tests/Main.hs +47 -0
- valid_word/java_tests/Main.java +24 -0
- valid_word/meta.json +72 -0
- valid_word/ocaml_tests/main.ml +51 -0
- valid_word/scala_tests/MySuite.scala +44 -0
- visit_array_positions_to_maximize_score/.DS_Store +0 -0
- visit_array_positions_to_maximize_score/haskell_tests/Main.hs +24 -0
- visit_array_positions_to_maximize_score/java_tests/Main.java +21 -0
- visit_array_positions_to_maximize_score/meta.json +659 -0
- visit_array_positions_to_maximize_score/ocaml_tests/main.ml +26 -0
- visit_array_positions_to_maximize_score/scala_tests/MySuite.scala +12 -0
- vowels_game_in_a_string/haskell_tests/Main.hs +0 -0
- vowels_game_in_a_string/java_tests/Main.java +20 -0
- vowels_game_in_a_string/meta.json +0 -0
- vowels_game_in_a_string/ocaml_tests/main.ml +0 -0
- vowels_game_in_a_string/scala_tests/MySuite.scala +0 -0
- water_bottles_ii/haskell_tests/Main.hs +45 -0
- water_bottles_ii/java_tests/Main.java +21 -0
- water_bottles_ii/meta.json +97 -0
- water_bottles_ii/ocaml_tests/main.ml +50 -0
- water_bottles_ii/scala_tests/MySuite.scala +44 -0
- ways_to_express_an_integer_as_sum_of_powers/.DS_Store +0 -0
- ways_to_express_an_integer_as_sum_of_powers/haskell_tests/Main.hs +24 -0
- ways_to_express_an_integer_as_sum_of_powers/java_tests/Main.java +21 -0
- ways_to_express_an_integer_as_sum_of_powers/meta.json +97 -0
- ways_to_express_an_integer_as_sum_of_powers/ocaml_tests/main.ml +26 -0
- ways_to_express_an_integer_as_sum_of_powers/scala_tests/MySuite.scala +12 -0
- ways_to_split_array_into_good_subarrays/haskell_tests/Main.hs +0 -0
- ways_to_split_array_into_good_subarrays/java_tests/Main.java +20 -0
- ways_to_split_array_into_good_subarrays/meta.json +0 -0
- ways_to_split_array_into_good_subarrays/ocaml_tests/main.ml +0 -0
- ways_to_split_array_into_good_subarrays/scala_tests/MySuite.scala +0 -0
- words_within_two_edits_of_dictionary/.DS_Store +0 -0
- words_within_two_edits_of_dictionary/haskell_tests/Main.hs +24 -0
- words_within_two_edits_of_dictionary/java_tests/Main.java +21 -0
- words_within_two_edits_of_dictionary/meta.json +26 -0
- words_within_two_edits_of_dictionary/ocaml_tests/main.ml +26 -0
- words_within_two_edits_of_dictionary/scala_tests/MySuite.scala +12 -0
- zero_array_transformation_i/haskell_tests/Main.hs +3 -0
- zero_array_transformation_i/java_tests/Main.java +21 -0
- zero_array_transformation_i/meta.json +3 -0
.gitattributes
CHANGED
|
@@ -288,3 +288,6 @@ sum_of_distances/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
| 288 |
sum_of_matrix_after_queries/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 289 |
task_scheduler_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 290 |
total_cost_to_hire_k_workers/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
sum_of_matrix_after_queries/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 289 |
task_scheduler_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 290 |
total_cost_to_hire_k_workers/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 291 |
+
zero_array_transformation_i/haskell_tests/Main.hs filter=lfs diff=lfs merge=lfs -text
|
| 292 |
+
zero_array_transformation_i/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 293 |
+
zero_array_transformation_i/ocaml_tests/main.ml filter=lfs diff=lfs merge=lfs -text
|
unique_3_digit_even_numbers/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let totalNumbers (digits: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 12 (totalNumbers [1;2;3;4])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 2 (totalNumbers [0;2;2])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 1 (totalNumbers [6;6;6])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 0 (totalNumbers [1;3;5])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 0 (totalNumbers [7; 9; 2; 1])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 0 (totalNumbers [1; 7; 4; 7; 8; 4; 7; 2; 2])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 0 (totalNumbers [1; 3; 1])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal 0 (totalNumbers [4; 8; 0; 3; 0; 1; 7])
|
| 27 |
+
|
| 28 |
+
let test9 _ = assert_equal 0 (totalNumbers [3; 3; 1; 8; 8; 5; 4; 5])
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
(* Grouping test cases *)
|
| 32 |
+
let suite = "Test Suite for totalNumbers" >::: [
|
| 33 |
+
|
| 34 |
+
"test1" >:: test1;
|
| 35 |
+
"test2" >:: test2;
|
| 36 |
+
"test3" >:: test3;
|
| 37 |
+
"test4" >:: test4;
|
| 38 |
+
"test5" >:: test5;
|
| 39 |
+
"test6" >:: test6;
|
| 40 |
+
"test7" >:: test7;
|
| 41 |
+
"test8" >:: test8;
|
| 42 |
+
"test9" >:: test9;
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
(* Running the tests *)
|
| 47 |
+
let () = run_test_tt_main suite
|
| 48 |
+
end
|
unique_3_digit_even_numbers/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.totalNumbers(List(1,2,3,4)), 12)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.totalNumbers(List(0,2,2)), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.totalNumbers(List(6,6,6)), 1)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.totalNumbers(List(1,3,5)), 0)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.totalNumbers(7,9,2,1), 6)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.totalNumbers(1,7,4,7,8,4,7,2,2), 59)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.totalNumbers(1,3,1), 0)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.totalNumbers(4,8,0,3,0,1,7), 57)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.totalNumbers(3,3,1,8,8,5,4,5), 37)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
}
|
using_a_robot_to_print_the_lexicographically_smallest_string/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
using_a_robot_to_print_the_lexicographically_smallest_string/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
|
| 7 |
+
--Program end
|
| 8 |
+
|
| 9 |
+
-- Test cases
|
| 10 |
+
|
| 11 |
+
test1 :: Test
|
| 12 |
+
test1 = TestCase (assertEqual "for (robotWithString \"zza \")," "azz" (robotWithString "zza"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (robotWithString \"bac \")," "abc" (robotWithString "bac"))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (robotWithString \"bdda \")," "addb" (robotWithString "bdda"))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
-- Grouping test cases
|
| 22 |
+
tests :: Test
|
| 23 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
|
| 24 |
+
|
| 25 |
+
-- Running the tests
|
| 26 |
+
main :: IO Counts
|
| 27 |
+
main = runTestTT tests
|
using_a_robot_to_print_the_lexicographically_smallest_string/java_tests/Main.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals("zza", robotWithString("zza"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals("bac", robotWithString("bac"));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals("bdda", robotWithString("bdda"));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
using_a_robot_to_print_the_lexicographically_smallest_string/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
using_a_robot_to_print_the_lexicographically_smallest_string/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal "azz" (robotWithString "zza")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal "abc" (robotWithString "bac")
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal "addb" (robotWithString "bdda")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for robotWithString" >::: [
|
| 20 |
+
|
| 21 |
+
"test1" >:: test1;
|
| 22 |
+
"test2" >:: test2;
|
| 23 |
+
"test3" >:: test3;
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Running the tests *)
|
| 28 |
+
let () = run_test_tt_main suite
|
| 29 |
+
end
|
using_a_robot_to_print_the_lexicographically_smallest_string/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.robotWithString("zza"), "azz")
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.robotWithString("bac"), "abc")
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.robotWithString("bdda"), "addb")
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
valid_word/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
isValid :: String -> Bool
|
| 7 |
+
isValid word = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (isValid \"234Adas \")," True (isValid "234Adas"))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (isValid \"b3 \")," False (isValid "b3"))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (isValid \"a3$e \")," False (isValid "a3$e"))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (isValid \"Gj#UP \")," False (isValid "Gj#UP"))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (isValid \"ifhka@1pjwpS@Om7 \")," False (isValid "ifhka@1pjwpS@Om7"))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (isValid \"btCM6QrVaYtHIZ#1Ueg \")," False (isValid "btCM6QrVaYtHIZ#1Ueg"))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (isValid \"t@6YzUK600NKB9afj \")," False (isValid "t@6YzUK600NKB9afj"))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (isValid \"cBo \")," True (isValid "cBo"))
|
| 36 |
+
|
| 37 |
+
test9 :: Test
|
| 38 |
+
test9 = TestCase (assertEqual "for (isValid \"2LevwlR \")," True (isValid "2LevwlR"))
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
-- Grouping test cases
|
| 42 |
+
tests :: Test
|
| 43 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6, TestLabel "Test7" test7, TestLabel "Test8" test8, TestLabel "Test9" test9]
|
| 44 |
+
|
| 45 |
+
-- Running the tests
|
| 46 |
+
main :: IO Counts
|
| 47 |
+
main = runTestTT tests
|
valid_word/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, isValid("234Adas"));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(false, isValid("b3"));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(false, isValid("a3$e"));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
valid_word/meta.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3396,
|
| 3 |
+
"name": "valid_word",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/valid-word/",
|
| 6 |
+
"date": "2024-04-28 00:00:00",
|
| 7 |
+
"task_description": "A word is considered **valid** if: It contains a **minimum** of 3 characters. It contains only digits (0-9), and English letters (uppercase and lowercase). It includes **at least** one **vowel**. It includes **at least** one **consonant**. You are given a string `word`. Return `true` if `word` is valid, otherwise, return `false`. **Notes:** `'a'`, `'e'`, `'i'`, `'o'`, `'u'`, and their uppercases are **vowels**. A **consonant** is an English letter that is not a vowel. **Example 1:** **Input:** word = \"234Adas\" **Output:** true **Explanation:** This word satisfies the conditions. **Example 2:** **Input:** word = \"b3\" **Output:** false **Explanation:** The length of this word is fewer than 3, and does not have a vowel. **Example 3:** **Input:** word = \"a3$e\" **Output:** false **Explanation:** This word contains a `'$'` character and does not have a consonant. **Constraints:** `1 <= word.length <= 20` `word` consists of English uppercase and lowercase letters, digits, `'@'`, `'#'`, and `'$'`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "word = \"234Adas\"",
|
| 12 |
+
"output": "true "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "word = \"b3\"",
|
| 17 |
+
"output": "false "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "word = \"a3$e\"",
|
| 22 |
+
"output": "false "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": "Gj#UP",
|
| 28 |
+
"output": false
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"input": "ifhka@1pjwpS@Om7",
|
| 32 |
+
"output": false
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": "btCM6QrVaYtHIZ#1Ueg",
|
| 36 |
+
"output": false
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": "t@6YzUK600NKB9afj",
|
| 40 |
+
"output": false
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": "cBo",
|
| 44 |
+
"output": true
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"input": "2LevwlR",
|
| 48 |
+
"output": true
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"input": "J28oLv3MqiGs",
|
| 52 |
+
"output": true
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"input": "28oazDB37nk",
|
| 56 |
+
"output": true
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": "zAXWzgNJmdk1BZitNF",
|
| 60 |
+
"output": true
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"input": "mXCmEg7YQV",
|
| 64 |
+
"output": true
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"haskell_template": "isValid :: String -> Bool\nisValid word ",
|
| 68 |
+
"ocaml_template": "let isValid (word: string) : bool = ",
|
| 69 |
+
"scala_template": "def isValid(word: String): Boolean = { \n \n}",
|
| 70 |
+
"java_template": "class Solution {\n public boolean isValid(String word) {\n \n }\n}",
|
| 71 |
+
"python_template": "class Solution(object):\n def isValid(self, word):\n \"\"\"\n :type word: str\n :rtype: bool\n \"\"\"\n "
|
| 72 |
+
}
|
valid_word/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let isValid (word: string) : bool = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal true (isValid "234Adas")
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal false (isValid "b3")
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal false (isValid "a3$e")
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal false (isValid "Gj#UP")
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal false (isValid "ifhka@1pjwpS@Om7")
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal false (isValid "btCM6QrVaYtHIZ#1Ueg")
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal false (isValid "t@6YzUK600NKB9afj")
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal false (isValid "cBo")
|
| 27 |
+
|
| 28 |
+
let test9 _ = assert_equal false (isValid "2LevwlR")
|
| 29 |
+
|
| 30 |
+
let test10 _ = assert_equal false (isValid "J28oLv3MqiGs")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
(* Grouping test cases *)
|
| 34 |
+
let suite = "Test Suite for isValid" >::: [
|
| 35 |
+
|
| 36 |
+
"test1" >:: test1;
|
| 37 |
+
"test2" >:: test2;
|
| 38 |
+
"test3" >:: test3;
|
| 39 |
+
"test4" >:: test4;
|
| 40 |
+
"test5" >:: test5;
|
| 41 |
+
"test6" >:: test6;
|
| 42 |
+
"test7" >:: test7;
|
| 43 |
+
"test8" >:: test8;
|
| 44 |
+
"test9" >:: test9;
|
| 45 |
+
"test10" >:: test10;
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
(* Running the tests *)
|
| 50 |
+
let () = run_test_tt_main suite
|
| 51 |
+
end
|
valid_word/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.isValid("234Adas"), true)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.isValid("b3"), false)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.isValid("a3$e"), false)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.isValid(",G,j,#,U,P,"), false)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.isValid(",i,f,h,k,a,@,1,p,j,w,p,S,@,O,m,7,"), false)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.isValid(",b,t,C,M,6,Q,r,V,a,Y,t,H,I,Z,#,1,U,e,g,"), false)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.isValid(",t,@,6,Y,z,U,K,6,0,0,N,K,B,9,a,f,j,"), false)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.isValid(",c,B,o,"), true)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.isValid(",2,L,e,v,w,l,R,"), true)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.isValid(",J,2,8,o,L,v,3,M,q,i,G,s,"), true)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
visit_array_positions_to_maximize_score/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
visit_array_positions_to_maximize_score/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 (maxScore [2,3,6,1,9,2] 5)," 13 (maxScore [2,3,6,1,9,2] 5))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maxScore [2,4,6,8] 3)," 20 (maxScore [2,4,6,8] 3))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
-- Grouping test cases
|
| 19 |
+
tests :: Test
|
| 20 |
+
tests = TestList [TestLabel "Test1" test1]
|
| 21 |
+
|
| 22 |
+
-- Running the tests
|
| 23 |
+
main :: IO Counts
|
| 24 |
+
main = runTestTT tests
|
visit_array_positions_to_maximize_score/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(13, maxScore(new ArrayList<>(Arrays.asList(2,3,6,1,9,2)), 5));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(20, maxScore(new ArrayList<>(Arrays.asList(2,4,6,8)), 3));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
visit_array_positions_to_maximize_score/meta.json
ADDED
|
@@ -0,0 +1,659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2893,
|
| 3 |
+
"name": "visit_array_positions_to_maximize_score",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/visit-array-positions-to-maximize-score/",
|
| 6 |
+
"date": "1688774400000",
|
| 7 |
+
"task_description": "You are given a **0-indexed** integer array `nums` and a positive integer `x`. You are **initially** at position `0` in the array and you can visit other positions according to the following rules: If you are currently in position `i`, then you can move to **any** position `j` such that `i < j`. For each position `i` that you visit, you get a score of `nums[i]`. If you move from a position `i` to a position `j` and the **parities** of `nums[i]` and `nums[j]` differ, then you lose a score of `x`. Return _the **maximum** total score you can get_. **Note** that initially you have `nums[0]` points. **Example 1:** ``` **Input:** nums = [2,3,6,1,9,2], x = 5 **Output:** 13 **Explanation:** We can visit the following positions in the array: 0 -> 2 -> 3 -> 4. The corresponding values are 2, 6, 1 and 9. Since the integers 6 and 1 have different parities, the move 2 -> 3 will make you lose a score of x = 5. The total score will be: 2 + 6 + 1 + 9 - 5 = 13. ``` **Example 2:** ``` **Input:** nums = [2,4,6,8], x = 3 **Output:** 20 **Explanation:** All the integers in the array have the same parities, so we can visit all of them without losing any score. The total score is: 2 + 4 + 6 + 8 = 20. ``` **Constraints:** `2 <= nums.length <= 105` `1 <= nums[i], x <= 106`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [2,3,6,1,9,2], x = 5",
|
| 12 |
+
"output": "13 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [2,4,6,8], x = 3",
|
| 17 |
+
"output": "20 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
485218,
|
| 25 |
+
309709,
|
| 26 |
+
630635,
|
| 27 |
+
337575,
|
| 28 |
+
471891,
|
| 29 |
+
609441,
|
| 30 |
+
615815,
|
| 31 |
+
700447,
|
| 32 |
+
85332,
|
| 33 |
+
519324,
|
| 34 |
+
528124,
|
| 35 |
+
561172,
|
| 36 |
+
823184,
|
| 37 |
+
309613,
|
| 38 |
+
247626,
|
| 39 |
+
531839,
|
| 40 |
+
398557,
|
| 41 |
+
283267,
|
| 42 |
+
361606,
|
| 43 |
+
917018,
|
| 44 |
+
709132,
|
| 45 |
+
991857,
|
| 46 |
+
104164,
|
| 47 |
+
122268,
|
| 48 |
+
896020,
|
| 49 |
+
318965,
|
| 50 |
+
216425,
|
| 51 |
+
363123,
|
| 52 |
+
840228,
|
| 53 |
+
806757,
|
| 54 |
+
88360,
|
| 55 |
+
81391,
|
| 56 |
+
741015,
|
| 57 |
+
968506,
|
| 58 |
+
903142,
|
| 59 |
+
14202,
|
| 60 |
+
85318,
|
| 61 |
+
995900,
|
| 62 |
+
558618,
|
| 63 |
+
490698,
|
| 64 |
+
880065,
|
| 65 |
+
457288,
|
| 66 |
+
39493,
|
| 67 |
+
884068,
|
| 68 |
+
907319,
|
| 69 |
+
728076,
|
| 70 |
+
451136,
|
| 71 |
+
143959,
|
| 72 |
+
540174,
|
| 73 |
+
991389,
|
| 74 |
+
955279,
|
| 75 |
+
274109,
|
| 76 |
+
530754,
|
| 77 |
+
427419,
|
| 78 |
+
101773,
|
| 79 |
+
448682,
|
| 80 |
+
910600,
|
| 81 |
+
810696,
|
| 82 |
+
691453,
|
| 83 |
+
472803,
|
| 84 |
+
523554,
|
| 85 |
+
232254,
|
| 86 |
+
438324,
|
| 87 |
+
993193,
|
| 88 |
+
239326,
|
| 89 |
+
692257,
|
| 90 |
+
568214,
|
| 91 |
+
582839,
|
| 92 |
+
902547,
|
| 93 |
+
243549,
|
| 94 |
+
977298
|
| 95 |
+
],
|
| 96 |
+
419077
|
| 97 |
+
],
|
| 98 |
+
"output": 27825662
|
| 99 |
+
},
|
| 100 |
+
{
|
| 101 |
+
"input": [
|
| 102 |
+
[
|
| 103 |
+
999845,
|
| 104 |
+
2727,
|
| 105 |
+
218611,
|
| 106 |
+
750198,
|
| 107 |
+
372616,
|
| 108 |
+
729785,
|
| 109 |
+
849413,
|
| 110 |
+
429990,
|
| 111 |
+
20157,
|
| 112 |
+
224326,
|
| 113 |
+
445369,
|
| 114 |
+
673265,
|
| 115 |
+
960760,
|
| 116 |
+
827163,
|
| 117 |
+
369368,
|
| 118 |
+
926400,
|
| 119 |
+
598331,
|
| 120 |
+
395407
|
| 121 |
+
],
|
| 122 |
+
651414
|
| 123 |
+
],
|
| 124 |
+
"output": 5886610
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"input": [
|
| 128 |
+
[
|
| 129 |
+
219144,
|
| 130 |
+
945121,
|
| 131 |
+
887315,
|
| 132 |
+
297758,
|
| 133 |
+
623865,
|
| 134 |
+
913917,
|
| 135 |
+
524280,
|
| 136 |
+
157517,
|
| 137 |
+
903857,
|
| 138 |
+
128775,
|
| 139 |
+
289544,
|
| 140 |
+
376299,
|
| 141 |
+
955582,
|
| 142 |
+
844420,
|
| 143 |
+
221271,
|
| 144 |
+
962458,
|
| 145 |
+
796074,
|
| 146 |
+
56465,
|
| 147 |
+
889268,
|
| 148 |
+
576081,
|
| 149 |
+
437467,
|
| 150 |
+
81345,
|
| 151 |
+
781023,
|
| 152 |
+
278337,
|
| 153 |
+
415576,
|
| 154 |
+
106657,
|
| 155 |
+
333536,
|
| 156 |
+
548645,
|
| 157 |
+
227782,
|
| 158 |
+
391678,
|
| 159 |
+
771871,
|
| 160 |
+
622340,
|
| 161 |
+
677081,
|
| 162 |
+
911901,
|
| 163 |
+
788465,
|
| 164 |
+
61421,
|
| 165 |
+
118470,
|
| 166 |
+
841196,
|
| 167 |
+
838997,
|
| 168 |
+
341705,
|
| 169 |
+
90761,
|
| 170 |
+
292833,
|
| 171 |
+
74132,
|
| 172 |
+
829956,
|
| 173 |
+
332018,
|
| 174 |
+
678339,
|
| 175 |
+
553831,
|
| 176 |
+
27312,
|
| 177 |
+
89956,
|
| 178 |
+
224392,
|
| 179 |
+
104987,
|
| 180 |
+
781044,
|
| 181 |
+
709330,
|
| 182 |
+
648746,
|
| 183 |
+
658527,
|
| 184 |
+
976838,
|
| 185 |
+
322790,
|
| 186 |
+
630509,
|
| 187 |
+
393252,
|
| 188 |
+
126193,
|
| 189 |
+
439008,
|
| 190 |
+
532437,
|
| 191 |
+
230698,
|
| 192 |
+
381287,
|
| 193 |
+
438206,
|
| 194 |
+
550730,
|
| 195 |
+
907340,
|
| 196 |
+
969114,
|
| 197 |
+
829997,
|
| 198 |
+
643930,
|
| 199 |
+
975756,
|
| 200 |
+
294425,
|
| 201 |
+
326400,
|
| 202 |
+
888218,
|
| 203 |
+
515725,
|
| 204 |
+
866033,
|
| 205 |
+
589559,
|
| 206 |
+
933915,
|
| 207 |
+
262851,
|
| 208 |
+
32953,
|
| 209 |
+
129198,
|
| 210 |
+
355494,
|
| 211 |
+
383292,
|
| 212 |
+
61609,
|
| 213 |
+
898331,
|
| 214 |
+
628020,
|
| 215 |
+
873425,
|
| 216 |
+
208283,
|
| 217 |
+
575006
|
| 218 |
+
],
|
| 219 |
+
921560
|
| 220 |
+
],
|
| 221 |
+
"output": 29602252
|
| 222 |
+
},
|
| 223 |
+
{
|
| 224 |
+
"input": [
|
| 225 |
+
[
|
| 226 |
+
746704,
|
| 227 |
+
926919,
|
| 228 |
+
205461,
|
| 229 |
+
995257,
|
| 230 |
+
951303,
|
| 231 |
+
292435,
|
| 232 |
+
564947,
|
| 233 |
+
452281,
|
| 234 |
+
204849,
|
| 235 |
+
829104,
|
| 236 |
+
362162,
|
| 237 |
+
915433,
|
| 238 |
+
979427,
|
| 239 |
+
648430,
|
| 240 |
+
947824,
|
| 241 |
+
448045,
|
| 242 |
+
593267,
|
| 243 |
+
982565,
|
| 244 |
+
374609,
|
| 245 |
+
20137
|
| 246 |
+
],
|
| 247 |
+
900744
|
| 248 |
+
],
|
| 249 |
+
"output": 8752895
|
| 250 |
+
},
|
| 251 |
+
{
|
| 252 |
+
"input": [
|
| 253 |
+
[
|
| 254 |
+
781654,
|
| 255 |
+
255447,
|
| 256 |
+
639135,
|
| 257 |
+
399879,
|
| 258 |
+
767941,
|
| 259 |
+
721564,
|
| 260 |
+
853751,
|
| 261 |
+
747520,
|
| 262 |
+
167382,
|
| 263 |
+
167744,
|
| 264 |
+
844103,
|
| 265 |
+
810361,
|
| 266 |
+
640293,
|
| 267 |
+
285855,
|
| 268 |
+
261994,
|
| 269 |
+
129024,
|
| 270 |
+
123924,
|
| 271 |
+
605824,
|
| 272 |
+
423896,
|
| 273 |
+
498604,
|
| 274 |
+
94835,
|
| 275 |
+
363030,
|
| 276 |
+
335047,
|
| 277 |
+
665941,
|
| 278 |
+
681323,
|
| 279 |
+
231700,
|
| 280 |
+
683192,
|
| 281 |
+
466306,
|
| 282 |
+
774215,
|
| 283 |
+
825836,
|
| 284 |
+
199305,
|
| 285 |
+
131800,
|
| 286 |
+
641686,
|
| 287 |
+
45246,
|
| 288 |
+
941560,
|
| 289 |
+
149818,
|
| 290 |
+
970658,
|
| 291 |
+
528783,
|
| 292 |
+
752140,
|
| 293 |
+
36586,
|
| 294 |
+
690676,
|
| 295 |
+
444633,
|
| 296 |
+
114322,
|
| 297 |
+
769610,
|
| 298 |
+
480383,
|
| 299 |
+
357653,
|
| 300 |
+
878714,
|
| 301 |
+
862545,
|
| 302 |
+
587603,
|
| 303 |
+
390833,
|
| 304 |
+
424260,
|
| 305 |
+
774443,
|
| 306 |
+
532315,
|
| 307 |
+
495134,
|
| 308 |
+
936402,
|
| 309 |
+
802485,
|
| 310 |
+
200011,
|
| 311 |
+
606441,
|
| 312 |
+
991906,
|
| 313 |
+
714087,
|
| 314 |
+
345030,
|
| 315 |
+
190419,
|
| 316 |
+
220400,
|
| 317 |
+
831122,
|
| 318 |
+
966703,
|
| 319 |
+
25757,
|
| 320 |
+
320689,
|
| 321 |
+
569711,
|
| 322 |
+
727786,
|
| 323 |
+
591251,
|
| 324 |
+
569215,
|
| 325 |
+
241025,
|
| 326 |
+
864395,
|
| 327 |
+
574094,
|
| 328 |
+
5931,
|
| 329 |
+
782641,
|
| 330 |
+
700077,
|
| 331 |
+
145453,
|
| 332 |
+
540879,
|
| 333 |
+
996494,
|
| 334 |
+
708118,
|
| 335 |
+
920587,
|
| 336 |
+
239931,
|
| 337 |
+
976193,
|
| 338 |
+
927956,
|
| 339 |
+
973898,
|
| 340 |
+
682152,
|
| 341 |
+
283105,
|
| 342 |
+
271072,
|
| 343 |
+
472866,
|
| 344 |
+
807411,
|
| 345 |
+
412593,
|
| 346 |
+
997169,
|
| 347 |
+
143853,
|
| 348 |
+
404359,
|
| 349 |
+
454747,
|
| 350 |
+
293645,
|
| 351 |
+
312539,
|
| 352 |
+
893102,
|
| 353 |
+
55803,
|
| 354 |
+
912966,
|
| 355 |
+
771802,
|
| 356 |
+
86698
|
| 357 |
+
],
|
| 358 |
+
924773
|
| 359 |
+
],
|
| 360 |
+
"output": 35406375
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"input": [
|
| 364 |
+
[
|
| 365 |
+
685303,
|
| 366 |
+
903254,
|
| 367 |
+
747974,
|
| 368 |
+
951339,
|
| 369 |
+
29705,
|
| 370 |
+
591691,
|
| 371 |
+
273845,
|
| 372 |
+
130605,
|
| 373 |
+
395612,
|
| 374 |
+
552015,
|
| 375 |
+
409728,
|
| 376 |
+
426037,
|
| 377 |
+
702740,
|
| 378 |
+
727255,
|
| 379 |
+
884505,
|
| 380 |
+
97837,
|
| 381 |
+
276232,
|
| 382 |
+
544458,
|
| 383 |
+
765408,
|
| 384 |
+
456056
|
| 385 |
+
],
|
| 386 |
+
162921
|
| 387 |
+
],
|
| 388 |
+
"output": 9085310
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"input": [
|
| 392 |
+
[
|
| 393 |
+
720279,
|
| 394 |
+
491077,
|
| 395 |
+
929262,
|
| 396 |
+
811102,
|
| 397 |
+
538120,
|
| 398 |
+
58664,
|
| 399 |
+
812857,
|
| 400 |
+
732118,
|
| 401 |
+
965490,
|
| 402 |
+
109361,
|
| 403 |
+
32443,
|
| 404 |
+
757105,
|
| 405 |
+
177974,
|
| 406 |
+
317446,
|
| 407 |
+
265306,
|
| 408 |
+
895620,
|
| 409 |
+
847590,
|
| 410 |
+
623176,
|
| 411 |
+
824538,
|
| 412 |
+
925917,
|
| 413 |
+
398383,
|
| 414 |
+
534637,
|
| 415 |
+
990857,
|
| 416 |
+
696326,
|
| 417 |
+
49096,
|
| 418 |
+
870648,
|
| 419 |
+
203364,
|
| 420 |
+
41089,
|
| 421 |
+
132684,
|
| 422 |
+
963777,
|
| 423 |
+
363413,
|
| 424 |
+
68694,
|
| 425 |
+
857471,
|
| 426 |
+
128173,
|
| 427 |
+
765580,
|
| 428 |
+
490160,
|
| 429 |
+
449068,
|
| 430 |
+
306771,
|
| 431 |
+
566246,
|
| 432 |
+
420078,
|
| 433 |
+
539418,
|
| 434 |
+
54655,
|
| 435 |
+
916593,
|
| 436 |
+
910922,
|
| 437 |
+
743206,
|
| 438 |
+
553866,
|
| 439 |
+
848733,
|
| 440 |
+
236627,
|
| 441 |
+
261150,
|
| 442 |
+
924700,
|
| 443 |
+
878973,
|
| 444 |
+
186981,
|
| 445 |
+
565462,
|
| 446 |
+
525,
|
| 447 |
+
611685,
|
| 448 |
+
521951,
|
| 449 |
+
678702,
|
| 450 |
+
993405,
|
| 451 |
+
942796,
|
| 452 |
+
210511,
|
| 453 |
+
127747,
|
| 454 |
+
366006,
|
| 455 |
+
713828,
|
| 456 |
+
892370,
|
| 457 |
+
135016,
|
| 458 |
+
450209,
|
| 459 |
+
761673,
|
| 460 |
+
232611,
|
| 461 |
+
499677,
|
| 462 |
+
940790,
|
| 463 |
+
227214,
|
| 464 |
+
819458,
|
| 465 |
+
252108,
|
| 466 |
+
762853,
|
| 467 |
+
364644,
|
| 468 |
+
720568,
|
| 469 |
+
720584,
|
| 470 |
+
141822,
|
| 471 |
+
125417,
|
| 472 |
+
40518,
|
| 473 |
+
293733,
|
| 474 |
+
499619,
|
| 475 |
+
943839,
|
| 476 |
+
404157,
|
| 477 |
+
607741,
|
| 478 |
+
494348,
|
| 479 |
+
192297,
|
| 480 |
+
982460,
|
| 481 |
+
935069,
|
| 482 |
+
26877
|
| 483 |
+
],
|
| 484 |
+
480881
|
| 485 |
+
],
|
| 486 |
+
"output": 34987568
|
| 487 |
+
},
|
| 488 |
+
{
|
| 489 |
+
"input": [
|
| 490 |
+
[
|
| 491 |
+
462670,
|
| 492 |
+
796177,
|
| 493 |
+
569994,
|
| 494 |
+
642212,
|
| 495 |
+
931330,
|
| 496 |
+
440076,
|
| 497 |
+
343158,
|
| 498 |
+
745909,
|
| 499 |
+
35500,
|
| 500 |
+
794874,
|
| 501 |
+
20521,
|
| 502 |
+
939985,
|
| 503 |
+
641783,
|
| 504 |
+
562861,
|
| 505 |
+
304358,
|
| 506 |
+
926052,
|
| 507 |
+
384102,
|
| 508 |
+
688206,
|
| 509 |
+
929371,
|
| 510 |
+
953925,
|
| 511 |
+
48197,
|
| 512 |
+
176656,
|
| 513 |
+
57208,
|
| 514 |
+
411891,
|
| 515 |
+
270350,
|
| 516 |
+
270381,
|
| 517 |
+
716642,
|
| 518 |
+
147171,
|
| 519 |
+
466179,
|
| 520 |
+
593626,
|
| 521 |
+
9977,
|
| 522 |
+
59015,
|
| 523 |
+
805242,
|
| 524 |
+
643200,
|
| 525 |
+
920753,
|
| 526 |
+
151065,
|
| 527 |
+
546606,
|
| 528 |
+
799583,
|
| 529 |
+
434133,
|
| 530 |
+
293901,
|
| 531 |
+
260916,
|
| 532 |
+
572502,
|
| 533 |
+
762552,
|
| 534 |
+
633035,
|
| 535 |
+
129989,
|
| 536 |
+
350251,
|
| 537 |
+
984499,
|
| 538 |
+
514240,
|
| 539 |
+
275326,
|
| 540 |
+
123348,
|
| 541 |
+
442797,
|
| 542 |
+
699144,
|
| 543 |
+
869460,
|
| 544 |
+
476632,
|
| 545 |
+
696178,
|
| 546 |
+
518067,
|
| 547 |
+
832087,
|
| 548 |
+
872870,
|
| 549 |
+
188732,
|
| 550 |
+
990938,
|
| 551 |
+
663217,
|
| 552 |
+
29636,
|
| 553 |
+
796004,
|
| 554 |
+
964155,
|
| 555 |
+
318754,
|
| 556 |
+
34748,
|
| 557 |
+
771617,
|
| 558 |
+
557144,
|
| 559 |
+
999561,
|
| 560 |
+
814347,
|
| 561 |
+
871317,
|
| 562 |
+
438929,
|
| 563 |
+
717510,
|
| 564 |
+
981,
|
| 565 |
+
842827,
|
| 566 |
+
599623,
|
| 567 |
+
342621,
|
| 568 |
+
838682,
|
| 569 |
+
167817,
|
| 570 |
+
290618,
|
| 571 |
+
753749,
|
| 572 |
+
419958,
|
| 573 |
+
82758,
|
| 574 |
+
535127,
|
| 575 |
+
984470,
|
| 576 |
+
132978,
|
| 577 |
+
998733,
|
| 578 |
+
535645,
|
| 579 |
+
836354,
|
| 580 |
+
998251,
|
| 581 |
+
734529,
|
| 582 |
+
742406,
|
| 583 |
+
359529,
|
| 584 |
+
450334,
|
| 585 |
+
692664,
|
| 586 |
+
292495,
|
| 587 |
+
901948,
|
| 588 |
+
962035,
|
| 589 |
+
298841
|
| 590 |
+
],
|
| 591 |
+
751120
|
| 592 |
+
],
|
| 593 |
+
"output": 34041581
|
| 594 |
+
},
|
| 595 |
+
{
|
| 596 |
+
"input": [
|
| 597 |
+
[
|
| 598 |
+
206967,
|
| 599 |
+
84782,
|
| 600 |
+
802976,
|
| 601 |
+
761732,
|
| 602 |
+
666544,
|
| 603 |
+
270193,
|
| 604 |
+
461535,
|
| 605 |
+
915356,
|
| 606 |
+
273148,
|
| 607 |
+
148439,
|
| 608 |
+
521369,
|
| 609 |
+
65830,
|
| 610 |
+
218719
|
| 611 |
+
],
|
| 612 |
+
316667
|
| 613 |
+
],
|
| 614 |
+
"output": 4065092
|
| 615 |
+
},
|
| 616 |
+
{
|
| 617 |
+
"input": [
|
| 618 |
+
[
|
| 619 |
+
665458,
|
| 620 |
+
844254,
|
| 621 |
+
688328,
|
| 622 |
+
194703,
|
| 623 |
+
659042,
|
| 624 |
+
568523,
|
| 625 |
+
806280,
|
| 626 |
+
520965,
|
| 627 |
+
921443,
|
| 628 |
+
831861,
|
| 629 |
+
448737,
|
| 630 |
+
646179,
|
| 631 |
+
7889,
|
| 632 |
+
218683,
|
| 633 |
+
854168,
|
| 634 |
+
906592,
|
| 635 |
+
66680,
|
| 636 |
+
507722,
|
| 637 |
+
245058,
|
| 638 |
+
123216,
|
| 639 |
+
535940,
|
| 640 |
+
38543,
|
| 641 |
+
359563,
|
| 642 |
+
406925,
|
| 643 |
+
963735,
|
| 644 |
+
627967,
|
| 645 |
+
739074,
|
| 646 |
+
220999,
|
| 647 |
+
100262
|
| 648 |
+
],
|
| 649 |
+
495738
|
| 650 |
+
],
|
| 651 |
+
"output": 11751612
|
| 652 |
+
}
|
| 653 |
+
],
|
| 654 |
+
"haskell_template": "maxScore :: [Int] -> Int -> Int\nmaxScore nums x ",
|
| 655 |
+
"ocaml_template": "let maxScore (nums: int list) (x: int) : int = ",
|
| 656 |
+
"scala_template": "def maxScore(nums: List[Int],x: Int): Int = { \n \n}",
|
| 657 |
+
"java_template": "public static int maxScore(List<Integer> nums, int x) {\n\n}",
|
| 658 |
+
"python_template": "class Solution(object):\n def maxScore(self, nums, x):\n \"\"\"\n :type nums: List[int]\n :type x: int\n :rtype: int\n \"\"\"\n "
|
| 659 |
+
}
|
visit_array_positions_to_maximize_score/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 13 (maxScore [2;3;6;1;9;2] 5)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 20 (maxScore [2;4;6;8] 3)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for maxScore" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
visit_array_positions_to_maximize_score/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.maxScore(List(2,3,6,1,9,2),5), 13)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.maxScore(List(2,4,6,8),3), 20)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
vowels_game_in_a_string/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vowels_game_in_a_string/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(true, doesAliceWin("leetcoder"));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(false, doesAliceWin("bbcd"));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
vowels_game_in_a_string/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vowels_game_in_a_string/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vowels_game_in_a_string/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
water_bottles_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 (maxBottlesDrunk 13 6)," 15 (maxBottlesDrunk 13 6))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maxBottlesDrunk 10 3)," 13 (maxBottlesDrunk 10 3))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (maxBottlesDrunk 6 68)," 6 (maxBottlesDrunk 6 68))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (maxBottlesDrunk 57 95)," 57 (maxBottlesDrunk 57 95))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (maxBottlesDrunk 52 64)," 52 (maxBottlesDrunk 52 64))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (maxBottlesDrunk 49 47)," 50 (maxBottlesDrunk 49 47))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (maxBottlesDrunk 28 47)," 28 (maxBottlesDrunk 28 47))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (maxBottlesDrunk 30 3)," 36 (maxBottlesDrunk 30 3))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (maxBottlesDrunk 24 8)," 26 (maxBottlesDrunk 24 8))
|
| 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
|
water_bottles_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(15, maxBottlesDrunk(13, 6));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(13, maxBottlesDrunk(10, 3));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
water_bottles_ii/meta.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3336,
|
| 3 |
+
"name": "water_bottles_ii",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/water-bottles-ii/",
|
| 6 |
+
"date": "2024-03-24 00:00:00",
|
| 7 |
+
"task_description": "You are given two integers `numBottles` and `numExchange`. `numBottles` represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations: Drink any number of full water bottles turning them into empty bottles. Exchange `numExchange` empty bottles with one full water bottle. Then, increase `numExchange` by one. Note that you cannot exchange multiple batches of empty bottles for the same value of `numExchange`. For example, if `numBottles == 3` and `numExchange == 1`, you cannot exchange `3` empty water bottles for `3` full bottles. Return _the **maximum** number of water bottles you can drink_. **Example 1:** ``` **Input:** numBottles = 13, numExchange = 6 **Output:** 15 **Explanation:** The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk. ``` **Example 2:** ``` **Input:** numBottles = 10, numExchange = 3 **Output:** 13 **Explanation:** The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk. ``` **Constraints:** `1 <= numBottles <= 100 ` `1 <= numExchange <= 100`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "numBottles = 13, numExchange = 6",
|
| 12 |
+
"output": "15 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "numBottles = 10, numExchange = 3",
|
| 17 |
+
"output": "13 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
6,
|
| 24 |
+
68
|
| 25 |
+
],
|
| 26 |
+
"output": 6
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"input": [
|
| 30 |
+
57,
|
| 31 |
+
95
|
| 32 |
+
],
|
| 33 |
+
"output": 57
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"input": [
|
| 37 |
+
52,
|
| 38 |
+
64
|
| 39 |
+
],
|
| 40 |
+
"output": 52
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": [
|
| 44 |
+
49,
|
| 45 |
+
47
|
| 46 |
+
],
|
| 47 |
+
"output": 50
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"input": [
|
| 51 |
+
28,
|
| 52 |
+
47
|
| 53 |
+
],
|
| 54 |
+
"output": 28
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"input": [
|
| 58 |
+
30,
|
| 59 |
+
3
|
| 60 |
+
],
|
| 61 |
+
"output": 36
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"input": [
|
| 65 |
+
24,
|
| 66 |
+
8
|
| 67 |
+
],
|
| 68 |
+
"output": 26
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"input": [
|
| 72 |
+
74,
|
| 73 |
+
48
|
| 74 |
+
],
|
| 75 |
+
"output": 75
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"input": [
|
| 79 |
+
9,
|
| 80 |
+
96
|
| 81 |
+
],
|
| 82 |
+
"output": 9
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"input": [
|
| 86 |
+
93,
|
| 87 |
+
41
|
| 88 |
+
],
|
| 89 |
+
"output": 95
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"haskell_template": "maxBottlesDrunk :: Int -> Int -> Int\nmaxBottlesDrunk numBottles numExchange ",
|
| 93 |
+
"ocaml_template": "let maxBottlesDrunk (numBottles: int) (numExchange: int) : int = ",
|
| 94 |
+
"scala_template": "def maxBottlesDrunk(numBottles: Int,numExchange: Int): Int = { \n \n}",
|
| 95 |
+
"java_template": "class Solution {\n public int maxBottlesDrunk(int numBottles, int numExchange) {\n \n }\n}",
|
| 96 |
+
"python_template": "class Solution(object):\n def maxBottlesDrunk(self, numBottles, numExchange):\n \"\"\"\n :type numBottles: int\n :type numExchange: int\n :rtype: int\n \"\"\"\n "
|
| 97 |
+
}
|
water_bottles_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 15 (maxBottlesDrunk 13 6)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 13 (maxBottlesDrunk 10 3)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 6 (maxBottlesDrunk 6 68)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 57 (maxBottlesDrunk 57 95)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 52 (maxBottlesDrunk 52 64)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 50 (maxBottlesDrunk 49 47)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 28 (maxBottlesDrunk 28 47)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 36 (maxBottlesDrunk 30 3)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 26 (maxBottlesDrunk 24 8)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 75 (maxBottlesDrunk 74 48)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for maxBottlesDrunk" >::: [
|
| 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
|
water_bottles_ii/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.maxBottlesDrunk(13,6), 15)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.maxBottlesDrunk(10,3), 13)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.maxBottlesDrunk(6,68), 6)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.maxBottlesDrunk(57,95), 57)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.maxBottlesDrunk(52,64), 52)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.maxBottlesDrunk(49,47), 50)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.maxBottlesDrunk(28,47), 28)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.maxBottlesDrunk(30,3), 36)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.maxBottlesDrunk(24,8), 26)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.maxBottlesDrunk(74,48), 75)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
ways_to_express_an_integer_as_sum_of_powers/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
ways_to_express_an_integer_as_sum_of_powers/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 (numberOfWays 10 2)," 1 (numberOfWays 10 2))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (numberOfWays 4 1)," 2 (numberOfWays 4 1))
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
-- Grouping test cases
|
| 19 |
+
tests :: Test
|
| 20 |
+
tests = TestList [TestLabel "Test1" test1]
|
| 21 |
+
|
| 22 |
+
-- Running the tests
|
| 23 |
+
main :: IO Counts
|
| 24 |
+
main = runTestTT tests
|
ways_to_express_an_integer_as_sum_of_powers/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, numberOfWays(10, 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, numberOfWays(4, 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
ways_to_express_an_integer_as_sum_of_powers/meta.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2882,
|
| 3 |
+
"name": "ways_to_express_an_integer_as_sum_of_powers",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/ways-to-express-an-integer-as-sum-of-powers/",
|
| 6 |
+
"date": "1688774400000",
|
| 7 |
+
"task_description": "Given two **positive** integers `n` and `x`. Return _the number of ways _`n`_ can be expressed as the sum of the _`xth`_ power of **unique** positive integers, in other words, the number of sets of unique integers _`[n1, n2, ..., nk]`_ where _`n = n1x + n2x + ... + nkx`_._ Since the result can be very large, return it modulo `109 + 7`. For example, if `n = 160` and `x = 3`, one way to express `n` is `n = 23 + 33 + 53`. **Example 1:** ``` **Input:** n = 10, x = 2 **Output:** 1 **Explanation:** We can express n as the following: n = 32 + 12 = 10. It can be shown that it is the only way to express 10 as the sum of the 2nd power of unique integers. ``` **Example 2:** ``` **Input:** n = 4, x = 1 **Output:** 2 **Explanation:** We can express n in the following ways: - n = 41 = 4. - n = 31 + 11 = 4. ``` **Constraints:** `1 <= n <= 300` `1 <= x <= 5`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "n = 10, x = 2",
|
| 12 |
+
"output": "1 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "n = 4, x = 1",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
50,
|
| 24 |
+
3
|
| 25 |
+
],
|
| 26 |
+
"output": 0
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"input": [
|
| 30 |
+
162,
|
| 31 |
+
1
|
| 32 |
+
],
|
| 33 |
+
"output": 43812110
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"input": [
|
| 37 |
+
27,
|
| 38 |
+
3
|
| 39 |
+
],
|
| 40 |
+
"output": 1
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": [
|
| 44 |
+
240,
|
| 45 |
+
5
|
| 46 |
+
],
|
| 47 |
+
"output": 0
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"input": [
|
| 51 |
+
106,
|
| 52 |
+
3
|
| 53 |
+
],
|
| 54 |
+
"output": 0
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"input": [
|
| 58 |
+
250,
|
| 59 |
+
1
|
| 60 |
+
],
|
| 61 |
+
"output": 519280072
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"input": [
|
| 65 |
+
21,
|
| 66 |
+
3
|
| 67 |
+
],
|
| 68 |
+
"output": 0
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"input": [
|
| 72 |
+
208,
|
| 73 |
+
4
|
| 74 |
+
],
|
| 75 |
+
"output": 0
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"input": [
|
| 79 |
+
2,
|
| 80 |
+
5
|
| 81 |
+
],
|
| 82 |
+
"output": 0
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"input": [
|
| 86 |
+
18,
|
| 87 |
+
3
|
| 88 |
+
],
|
| 89 |
+
"output": 0
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"haskell_template": "numberOfWays :: Int -> Int -> Int\nnumberOfWays n x ",
|
| 93 |
+
"ocaml_template": "let numberOfWays (n: int) (x: int) : int = ",
|
| 94 |
+
"scala_template": "def numberOfWays(n: Int,x: Int): Int = { \n \n}",
|
| 95 |
+
"java_template": "public static int numberOfWays(int n, int x) {\n\n}",
|
| 96 |
+
"python_template": "class Solution(object):\n def numberOfWays(self, n, x):\n \"\"\"\n :type n: int\n :type x: int\n :rtype: int\n \"\"\"\n "
|
| 97 |
+
}
|
ways_to_express_an_integer_as_sum_of_powers/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 1 (numberOfWays 10 2)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (numberOfWays 4 1)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for numberOfWays" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
ways_to_express_an_integer_as_sum_of_powers/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.numberOfWays(10,2), 1)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.numberOfWays(4,1), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
ways_to_split_array_into_good_subarrays/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ways_to_split_array_into_good_subarrays/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(3, numberOfGoodSubarraySplits(Arrays.asList(0,1,0,0,1)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(1, numberOfGoodSubarraySplits(Arrays.asList(0,1,0)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
ways_to_split_array_into_good_subarrays/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ways_to_split_array_into_good_subarrays/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
ways_to_split_array_into_good_subarrays/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
words_within_two_edits_of_dictionary/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
words_within_two_edits_of_dictionary/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 (twoEditWords [ \"word \", \"note \", \"ants \", \"wood \"] [ \"wood \", \"joke \", \"moat \"])," ["word","note","wood"] (twoEditWords ["word","note","ants","wood"] ["wood","joke","moat"]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (twoEditWords [ \"yes \"] [ \"not \"])," [] (twoEditWords ["yes"] ["not"]))
|
| 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
|
words_within_two_edits_of_dictionary/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("word","note","wood")), twoEditWords(new ArrayList<>(Arrays.asList("word","note","ants","wood")), new ArrayList<>(Arrays.asList("wood","joke","moat"))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(), twoEditWords(new ArrayList<>(Arrays.asList("yes")), new ArrayList<>(Arrays.asList("not"))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
words_within_two_edits_of_dictionary/meta.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2550,
|
| 3 |
+
"name": "words_within_two_edits_of_dictionary",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/words-within-two-edits-of-dictionary/",
|
| 6 |
+
"date": "1665792000000",
|
| 7 |
+
"task_description": "You are given two string arrays, `queries` and `dictionary`. All words in each array comprise of lowercase English letters and have the same length. In one **edit** you can take a word from `queries`, and change any letter in it to any other letter. Find all words from `queries` that, after a **maximum** of two edits, equal some word from `dictionary`. Return_ a list of all words from _`queries`_, __that match with some word from _`dictionary`_ after a maximum of **two edits**_. Return the words in the **same order** they appear in `queries`. **Example 1:** ``` **Input:** queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"] **Output:** [\"word\",\"note\",\"wood\"] **Explanation:** - Changing the 'r' in \"word\" to 'o' allows it to equal the dictionary word \"wood\". - Changing the 'n' to 'j' and the 't' to 'k' in \"note\" changes it to \"joke\". - It would take more than 2 edits for \"ants\" to equal a dictionary word. - \"wood\" can remain unchanged (0 edits) and match the corresponding dictionary word. Thus, we return [\"word\",\"note\",\"wood\"]. ``` **Example 2:** ``` **Input:** queries = [\"yes\"], dictionary = [\"not\"] **Output:** [] **Explanation:** Applying any two edits to \"yes\" cannot make it equal to \"not\". Thus, we return an empty array. ``` **Constraints:** `1 <= queries.length, dictionary.length <= 100` `n == queries[i].length == dictionary[j].length` `1 <= n <= 100` All `queries[i]` and `dictionary[j]` are composed of lowercase English letters.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "queries = [\"word\",\"note\",\"ants\",\"wood\"], dictionary = [\"wood\",\"joke\",\"moat\"]",
|
| 12 |
+
"output": "[\"word\",\"note\",\"wood\"] "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "queries = [\"yes\"], dictionary = [\"not\"]",
|
| 17 |
+
"output": "[] "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [],
|
| 21 |
+
"haskell_template": "twoEditWords :: [String] -> [String] -> [String]\ntwoEditWords queries dictionary ",
|
| 22 |
+
"ocaml_template": "let twoEditWords (queries: string list) (dictionary: string list) : string list = ",
|
| 23 |
+
"scala_template": "def twoEditWords(queries: List[String],dictionary: List[String]): List[String] = { \n \n}",
|
| 24 |
+
"java_template": "public static List<String> twoEditWords(List<String> queries, List<String> dictionary) {\n\n}",
|
| 25 |
+
"python_template": "class Solution(object):\n def twoEditWords(self, queries, dictionary):\n \"\"\"\n :type queries: List[str]\n :type dictionary: List[str]\n :rtype: List[str]\n \"\"\"\n "
|
| 26 |
+
}
|
words_within_two_edits_of_dictionary/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 ["word";"note";"wood"] (twoEditWords ["word";"note";"ants";"wood"] ["wood";"joke";"moat"])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal [] (twoEditWords ["yes"] ["not"])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for twoEditWords" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
words_within_two_edits_of_dictionary/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.twoEditWords(List("word","note","ants","wood"),List("wood","joke","moat")), List("word","note","wood"))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.twoEditWords(List("yes"),List("not")), List())
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
zero_array_transformation_i/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0daebcbe6691e34886a51ff26fff0eeb20a5984649dc95b236c0df2e05dd872f
|
| 3 |
+
size 20108791
|
zero_array_transformation_i/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(true, isZeroArray(new ArrayList<>(Arrays.asList(1,0,1)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(0,2))))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(false, isZeroArray(new ArrayList<>(Arrays.asList(4,3,2,1)), new ArrayList<>(Arrays.asList(new ArrayList<>(Arrays.asList(1,3)),new ArrayList<>(Arrays.asList(0,2))))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
zero_array_transformation_i/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:524fa10dc811c9b11aac14ca7bbb0b542cd2bf7e94ca0110221c69bebe83e248
|
| 3 |
+
size 75283191
|