4fd72f98993a86522f493405e676be94c9acfea805829bee0e1295ce16bba63c
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +3 -0
- move_pieces_to_obtain_a_string/.DS_Store +0 -0
- move_pieces_to_obtain_a_string/haskell_tests/Main.hs +27 -0
- move_pieces_to_obtain_a_string/java_tests/Main.java +25 -0
- move_pieces_to_obtain_a_string/meta.json +0 -0
- move_pieces_to_obtain_a_string/ocaml_tests/main.ml +29 -0
- move_pieces_to_obtain_a_string/scala_tests/MySuite.scala +16 -0
- movement_of_robots/haskell_tests/Main.hs +0 -0
- movement_of_robots/java_tests/Main.java +21 -0
- movement_of_robots/meta.json +3 -0
- movement_of_robots/ocaml_tests/main.ml +0 -0
- movement_of_robots/scala_tests/MySuite.scala +0 -0
- naming_a_company/java_tests/Main.java +20 -0
- neighboring_bitwise_xor/haskell_tests/Main.hs +0 -0
- neighboring_bitwise_xor/java_tests/Main.java +24 -0
- neighboring_bitwise_xor/meta.json +0 -0
- neighboring_bitwise_xor/ocaml_tests/main.ml +0 -0
- neighboring_bitwise_xor/scala_tests/MySuite.scala +0 -0
- neither_minimum_nor_maximum/haskell_tests/Main.hs +44 -0
- neither_minimum_nor_maximum/java_tests/Main.java +24 -0
- neither_minimum_nor_maximum/meta.json +286 -0
- neither_minimum_nor_maximum/ocaml_tests/main.ml +45 -0
- neither_minimum_nor_maximum/scala_tests/MySuite.scala +36 -0
- next_greater_element_iv/.DS_Store +0 -0
- next_greater_element_iv/haskell_tests/Main.hs +24 -0
- next_greater_element_iv/java_tests/Main.java +21 -0
- next_greater_element_iv/meta.json +3 -0
- next_greater_element_iv/ocaml_tests/main.ml +26 -0
- next_greater_element_iv/scala_tests/MySuite.scala +12 -0
- node_with_highest_edge_score/.DS_Store +0 -0
- node_with_highest_edge_score/haskell_tests/Main.hs +24 -0
- node_with_highest_edge_score/java_tests/Main.java +21 -0
- node_with_highest_edge_score/meta.json +3 -0
- node_with_highest_edge_score/ocaml_tests/main.ml +26 -0
- node_with_highest_edge_score/scala_tests/MySuite.scala +12 -0
- number_of_arithmetic_triplets/.DS_Store +0 -0
- number_of_arithmetic_triplets/haskell_tests/Main.hs +24 -0
- number_of_arithmetic_triplets/java_tests/Main.java +21 -0
- number_of_arithmetic_triplets/meta.json +1015 -0
- number_of_arithmetic_triplets/ocaml_tests/main.ml +26 -0
- number_of_arithmetic_triplets/scala_tests/MySuite.scala +12 -0
- number_of_beautiful_pairs/haskell_tests/Main.hs +41 -0
- number_of_beautiful_pairs/java_tests/Main.java +20 -0
- number_of_beautiful_pairs/meta.json +363 -0
- number_of_beautiful_pairs/ocaml_tests/main.ml +42 -0
- number_of_beautiful_pairs/scala_tests/MySuite.scala +32 -0
- number_of_beautiful_partitions/.DS_Store +0 -0
- number_of_beautiful_partitions/haskell_tests/Main.hs +27 -0
- number_of_beautiful_partitions/java_tests/Main.java +25 -0
- number_of_beautiful_partitions/meta.json +112 -0
.gitattributes
CHANGED
|
@@ -249,3 +249,6 @@ minimum_time_to_finish_the_race/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
| 249 |
minimum_time_to_repair_cars/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 250 |
minimum_total_cost_to_make_arrays_unequal/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 251 |
most_popular_video_creator/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
minimum_time_to_repair_cars/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 250 |
minimum_total_cost_to_make_arrays_unequal/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 251 |
most_popular_video_creator/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 252 |
+
movement_of_robots/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 253 |
+
next_greater_element_iv/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 254 |
+
node_with_highest_edge_score/meta.json filter=lfs diff=lfs merge=lfs -text
|
move_pieces_to_obtain_a_string/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
move_pieces_to_obtain_a_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 (canChange \"_L__R__R_ \" \"L______RR \")," True (canChange "_L__R__R_" "L______RR"))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (canChange \"R_L_ \" \"__LR \")," False (canChange "R_L_" "__LR"))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (canChange \"_R \" \"R_ \")," False (canChange "_R" "R_"))
|
| 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
|
move_pieces_to_obtain_a_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(true, canChange("_L__R__R_", "L______RR"));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(false, canChange("R_L_", "__LR"));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(false, canChange("_R", "R_"));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
move_pieces_to_obtain_a_string/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
move_pieces_to_obtain_a_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 true (canChange "_L__R__R_" "L______RR")
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal false (canChange "R_L_" "__LR")
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal false (canChange "_R" "R_")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for canChange" >::: [
|
| 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
|
move_pieces_to_obtain_a_string/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.canChange("_L__R__R_","L______RR"), true)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.canChange("R_L_","__LR"), false)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.canChange("_R","R_"), false)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
movement_of_robots/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
movement_of_robots/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(8, sumDistance(new ArrayList<>(Arrays.asList(-2,0,2)), "RLL", 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(5, sumDistance(new ArrayList<>(Arrays.asList(1,0)), "RL", 2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
movement_of_robots/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef8085e1f0e9af313b06e7e8542078c45fa03a877987d612fd9b63582da81d9a
|
| 3 |
+
size 11538066
|
movement_of_robots/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
movement_of_robots/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
naming_a_company/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(6, distinctNames(Arrays.asList("coffee","donuts","time","toffee")));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(0, distinctNames(Arrays.asList("lack","back")));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
neighboring_bitwise_xor/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
neighboring_bitwise_xor/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, doesValidArrayExist(Arrays.asList(1,1,0)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(true, doesValidArrayExist(Arrays.asList(1,1)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(false, doesValidArrayExist(Arrays.asList(1,0)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
neighboring_bitwise_xor/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
neighboring_bitwise_xor/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
neighboring_bitwise_xor/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
neither_minimum_nor_maximum/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
findNonMinOrMax :: [Int] -> Int
|
| 7 |
+
findNonMinOrMax nums = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (findNonMinOrMax [3,2,1,4])," 2 (findNonMinOrMax [3,2,1,4]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (findNonMinOrMax [1,2])," (-1) (findNonMinOrMax [1,2]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (findNonMinOrMax [2,1,3])," 2 (findNonMinOrMax [2,1,3]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (findNonMinOrMax [62, 86, 92, 47, 22, 36, 7, 99, 96, 84, 43, 48, 77, 41, 76, 59, 29, 32, 61, 26, 6, 42, 19, 18, 87, 24, 97, 14, 65, 98, 78, 72, 80, 16, 91, 21, 90, 94, 55, 25, 50, 51, 71, 5, 52, 8, 53, 67, 85, 56, 54, 58, 79, 88, 37, 11, 17, 81, 74, 89, 100, 23, 44, 57, 35, 66, 27, 20, 45, 12, 39, 38])," 36 (findNonMinOrMax [62, 86, 92, 47, 22, 36, 7, 99, 96, 84, 43, 48, 77, 41, 76, 59, 29, 32, 61, 26, 6, 42, 19, 18, 87, 24, 97, 14, 65, 98, 78, 72, 80, 16, 91, 21, 90, 94, 55, 25, 50, 51, 71, 5, 52, 8, 53, 67, 85, 56, 54, 58, 79, 88, 37, 11, 17, 81, 74, 89, 100, 23, 44, 57, 35, 66, 27, 20, 45, 12, 39, 38]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (findNonMinOrMax [90, 66, 94, 7, 88, 13])," 88 (findNonMinOrMax [90, 66, 94, 7, 88, 13]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (findNonMinOrMax [5, 64, 57, 98, 72, 92, 99, 12, 14, 18, 85, 62, 4, 77, 22, 81, 36, 63, 30, 55, 2, 27, 35])," 57 (findNonMinOrMax [5, 64, 57, 98, 72, 92, 99, 12, 14, 18, 85, 62, 4, 77, 22, 81, 36, 63, 30, 55, 2, 27, 35]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (findNonMinOrMax [49, 21, 100, 37, 41, 38, 57, 2, 15, 81, 68, 98, 34, 31, 50, 14, 5, 20, 91, 86, 73, 83, 52, 30, 94, 80, 62, 53, 82, 39, 32, 23, 70, 36, 40, 96, 93])," 37 (findNonMinOrMax [49, 21, 100, 37, 41, 38, 57, 2, 15, 81, 68, 98, 34, 31, 50, 14, 5, 20, 91, 86, 73, 83, 52, 30, 94, 80, 62, 53, 82, 39, 32, 23, 70, 36, 40, 96, 93]))
|
| 33 |
+
|
| 34 |
+
test8 :: Test
|
| 35 |
+
test8 = TestCase (assertEqual "for (findNonMinOrMax [83, 61, 74, 75, 22, 11, 9, 6, 88, 23, 51, 89, 37, 96, 13, 33, 49, 94, 69, 78, 79, 55, 39, 57, 98, 21, 44, 30, 65, 100, 10, 87, 58, 34, 56, 41, 85, 45, 3, 48, 59, 62, 76, 92, 18, 93, 54, 42, 8, 7, 12, 31, 17, 19, 82, 4, 91, 70, 14, 32, 25, 16, 26, 50, 66, 81, 53, 77, 35, 71, 99, 27, 63, 5, 64, 28, 43, 1, 15, 36, 84, 20, 29, 46, 38, 95, 24, 68, 97, 60, 40])," 74 (findNonMinOrMax [83, 61, 74, 75, 22, 11, 9, 6, 88, 23, 51, 89, 37, 96, 13, 33, 49, 94, 69, 78, 79, 55, 39, 57, 98, 21, 44, 30, 65, 100, 10, 87, 58, 34, 56, 41, 85, 45, 3, 48, 59, 62, 76, 92, 18, 93, 54, 42, 8, 7, 12, 31, 17, 19, 82, 4, 91, 70, 14, 32, 25, 16, 26, 50, 66, 81, 53, 77, 35, 71, 99, 27, 63, 5, 64, 28, 43, 1, 15, 36, 84, 20, 29, 46, 38, 95, 24, 68, 97, 60, 40]))
|
| 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
|
neither_minimum_nor_maximum/java_tests/Main.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
public class Main {
|
| 7 |
+
//Program start
|
| 8 |
+
|
| 9 |
+
//Program end
|
| 10 |
+
|
| 11 |
+
@Test
|
| 12 |
+
public void test1() {
|
| 13 |
+
assertEquals(2, findNonMinOrMax(Arrays.asList(3,2,1,4)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(-1, findNonMinOrMax(Arrays.asList(1,2)));
|
| 18 |
+
}
|
| 19 |
+
@Test
|
| 20 |
+
public void test3() {
|
| 21 |
+
assertEquals(2, findNonMinOrMax(Arrays.asList(2,1,3)));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
neither_minimum_nor_maximum/meta.json
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2836,
|
| 3 |
+
"name": "neither_minimum_nor_maximum",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/neither-minimum-nor-maximum/",
|
| 6 |
+
"date": "2023-06-04 00:00:00",
|
| 7 |
+
"task_description": "Given an integer array `nums` containing **distinct** **positive** integers, find and return **any** number from the array that is neither the **minimum** nor the **maximum** value in the array, or **`-1`** if there is no such number. Return _the selected integer._ **Example 1:** ``` **Input:** nums = [3,2,1,4] **Output:** 2 **Explanation:** In this example, the minimum value is 1 and the maximum value is 4. Therefore, either 2 or 3 can be valid answers. ``` **Example 2:** ``` **Input:** nums = [1,2] **Output:** -1 **Explanation:** Since there is no number in nums that is neither the maximum nor the minimum, we cannot select a number that satisfies the given condition. Therefore, there is no answer. ``` **Example 3:** ``` **Input:** nums = [2,1,3] **Output:** 2 **Explanation:** Since 2 is neither the maximum nor the minimum value in nums, it is the only valid answer. ``` **Constraints:** `1 <= nums.length <= 100` `1 <= nums[i] <= 100` All values in `nums` are distinct",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [3,2,1,4]",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [1,2]",
|
| 17 |
+
"output": "-1 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "nums = [2,1,3]",
|
| 22 |
+
"output": "2 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
62,
|
| 29 |
+
86,
|
| 30 |
+
92,
|
| 31 |
+
47,
|
| 32 |
+
22,
|
| 33 |
+
36,
|
| 34 |
+
7,
|
| 35 |
+
99,
|
| 36 |
+
96,
|
| 37 |
+
84,
|
| 38 |
+
43,
|
| 39 |
+
48,
|
| 40 |
+
77,
|
| 41 |
+
41,
|
| 42 |
+
76,
|
| 43 |
+
59,
|
| 44 |
+
29,
|
| 45 |
+
32,
|
| 46 |
+
61,
|
| 47 |
+
26,
|
| 48 |
+
6,
|
| 49 |
+
42,
|
| 50 |
+
19,
|
| 51 |
+
18,
|
| 52 |
+
87,
|
| 53 |
+
24,
|
| 54 |
+
97,
|
| 55 |
+
14,
|
| 56 |
+
65,
|
| 57 |
+
98,
|
| 58 |
+
78,
|
| 59 |
+
72,
|
| 60 |
+
80,
|
| 61 |
+
16,
|
| 62 |
+
91,
|
| 63 |
+
21,
|
| 64 |
+
90,
|
| 65 |
+
94,
|
| 66 |
+
55,
|
| 67 |
+
25,
|
| 68 |
+
50,
|
| 69 |
+
51,
|
| 70 |
+
71,
|
| 71 |
+
5,
|
| 72 |
+
52,
|
| 73 |
+
8,
|
| 74 |
+
53,
|
| 75 |
+
67,
|
| 76 |
+
85,
|
| 77 |
+
56,
|
| 78 |
+
54,
|
| 79 |
+
58,
|
| 80 |
+
79,
|
| 81 |
+
88,
|
| 82 |
+
37,
|
| 83 |
+
11,
|
| 84 |
+
17,
|
| 85 |
+
81,
|
| 86 |
+
74,
|
| 87 |
+
89,
|
| 88 |
+
100,
|
| 89 |
+
23,
|
| 90 |
+
44,
|
| 91 |
+
57,
|
| 92 |
+
35,
|
| 93 |
+
66,
|
| 94 |
+
27,
|
| 95 |
+
20,
|
| 96 |
+
45,
|
| 97 |
+
12,
|
| 98 |
+
39,
|
| 99 |
+
38
|
| 100 |
+
],
|
| 101 |
+
"output": 36
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"input": [
|
| 105 |
+
90,
|
| 106 |
+
66,
|
| 107 |
+
94,
|
| 108 |
+
7,
|
| 109 |
+
88,
|
| 110 |
+
13
|
| 111 |
+
],
|
| 112 |
+
"output": 88
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"input": [
|
| 116 |
+
5,
|
| 117 |
+
64,
|
| 118 |
+
57,
|
| 119 |
+
98,
|
| 120 |
+
72,
|
| 121 |
+
92,
|
| 122 |
+
99,
|
| 123 |
+
12,
|
| 124 |
+
14,
|
| 125 |
+
18,
|
| 126 |
+
85,
|
| 127 |
+
62,
|
| 128 |
+
4,
|
| 129 |
+
77,
|
| 130 |
+
22,
|
| 131 |
+
81,
|
| 132 |
+
36,
|
| 133 |
+
63,
|
| 134 |
+
30,
|
| 135 |
+
55,
|
| 136 |
+
2,
|
| 137 |
+
27,
|
| 138 |
+
35
|
| 139 |
+
],
|
| 140 |
+
"output": 57
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"input": [
|
| 144 |
+
49,
|
| 145 |
+
21,
|
| 146 |
+
100,
|
| 147 |
+
37,
|
| 148 |
+
41,
|
| 149 |
+
38,
|
| 150 |
+
57,
|
| 151 |
+
2,
|
| 152 |
+
15,
|
| 153 |
+
81,
|
| 154 |
+
68,
|
| 155 |
+
98,
|
| 156 |
+
34,
|
| 157 |
+
31,
|
| 158 |
+
50,
|
| 159 |
+
14,
|
| 160 |
+
5,
|
| 161 |
+
20,
|
| 162 |
+
91,
|
| 163 |
+
86,
|
| 164 |
+
73,
|
| 165 |
+
83,
|
| 166 |
+
52,
|
| 167 |
+
30,
|
| 168 |
+
94,
|
| 169 |
+
80,
|
| 170 |
+
62,
|
| 171 |
+
53,
|
| 172 |
+
82,
|
| 173 |
+
39,
|
| 174 |
+
32,
|
| 175 |
+
23,
|
| 176 |
+
70,
|
| 177 |
+
36,
|
| 178 |
+
40,
|
| 179 |
+
96,
|
| 180 |
+
93
|
| 181 |
+
],
|
| 182 |
+
"output": 37
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"input": [
|
| 186 |
+
83,
|
| 187 |
+
61,
|
| 188 |
+
74,
|
| 189 |
+
75,
|
| 190 |
+
22,
|
| 191 |
+
11,
|
| 192 |
+
9,
|
| 193 |
+
6,
|
| 194 |
+
88,
|
| 195 |
+
23,
|
| 196 |
+
51,
|
| 197 |
+
89,
|
| 198 |
+
37,
|
| 199 |
+
96,
|
| 200 |
+
13,
|
| 201 |
+
33,
|
| 202 |
+
49,
|
| 203 |
+
94,
|
| 204 |
+
69,
|
| 205 |
+
78,
|
| 206 |
+
79,
|
| 207 |
+
55,
|
| 208 |
+
39,
|
| 209 |
+
57,
|
| 210 |
+
98,
|
| 211 |
+
21,
|
| 212 |
+
44,
|
| 213 |
+
30,
|
| 214 |
+
65,
|
| 215 |
+
100,
|
| 216 |
+
10,
|
| 217 |
+
87,
|
| 218 |
+
58,
|
| 219 |
+
34,
|
| 220 |
+
56,
|
| 221 |
+
41,
|
| 222 |
+
85,
|
| 223 |
+
45,
|
| 224 |
+
3,
|
| 225 |
+
48,
|
| 226 |
+
59,
|
| 227 |
+
62,
|
| 228 |
+
76,
|
| 229 |
+
92,
|
| 230 |
+
18,
|
| 231 |
+
93,
|
| 232 |
+
54,
|
| 233 |
+
42,
|
| 234 |
+
8,
|
| 235 |
+
7,
|
| 236 |
+
12,
|
| 237 |
+
31,
|
| 238 |
+
17,
|
| 239 |
+
19,
|
| 240 |
+
82,
|
| 241 |
+
4,
|
| 242 |
+
91,
|
| 243 |
+
70,
|
| 244 |
+
14,
|
| 245 |
+
32,
|
| 246 |
+
25,
|
| 247 |
+
16,
|
| 248 |
+
26,
|
| 249 |
+
50,
|
| 250 |
+
66,
|
| 251 |
+
81,
|
| 252 |
+
53,
|
| 253 |
+
77,
|
| 254 |
+
35,
|
| 255 |
+
71,
|
| 256 |
+
99,
|
| 257 |
+
27,
|
| 258 |
+
63,
|
| 259 |
+
5,
|
| 260 |
+
64,
|
| 261 |
+
28,
|
| 262 |
+
43,
|
| 263 |
+
1,
|
| 264 |
+
15,
|
| 265 |
+
36,
|
| 266 |
+
84,
|
| 267 |
+
20,
|
| 268 |
+
29,
|
| 269 |
+
46,
|
| 270 |
+
38,
|
| 271 |
+
95,
|
| 272 |
+
24,
|
| 273 |
+
68,
|
| 274 |
+
97,
|
| 275 |
+
60,
|
| 276 |
+
40
|
| 277 |
+
],
|
| 278 |
+
"output": 74
|
| 279 |
+
}
|
| 280 |
+
],
|
| 281 |
+
"haskell_template": "findNonMinOrMax :: [Int] -> Int\nfindNonMinOrMax nums ",
|
| 282 |
+
"ocaml_template": "let findNonMinOrMax (nums: int list) : int = ",
|
| 283 |
+
"scala_template": "def findNonMinOrMax(nums: List[Int]): Int = { \n \n}",
|
| 284 |
+
"java_template": "class Solution {\n public int findNonMinOrMax(int[] nums) {\n \n }\n}",
|
| 285 |
+
"python_template": "class Solution(object):\n def findNonMinOrMax(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
|
| 286 |
+
}
|
neither_minimum_nor_maximum/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let findNonMinOrMax (nums: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 2 (findNonMinOrMax [3;2;1;4])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal (-1) (findNonMinOrMax [1;2])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 2 (findNonMinOrMax [2;1;3])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 2 (findNonMinOrMax [62; 86; 92; 47; 22; 36; 7; 99; 96; 84; 43; 48; 77; 41; 76; 59; 29; 32; 61; 26; 6; 42; 19; 18; 87; 24; 97; 14; 65; 98; 78; 72; 80; 16; 91; 21; 90; 94; 55; 25; 50; 51; 71; 5; 52; 8; 53; 67; 85; 56; 54; 58; 79; 88; 37; 11; 17; 81; 74; 89; 100; 23; 44; 57; 35; 66; 27; 20; 45; 12; 39; 38])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 2 (findNonMinOrMax [90; 66; 94; 7; 88; 13])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 2 (findNonMinOrMax [5; 64; 57; 98; 72; 92; 99; 12; 14; 18; 85; 62; 4; 77; 22; 81; 36; 63; 30; 55; 2; 27; 35])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 2 (findNonMinOrMax [49; 21; 100; 37; 41; 38; 57; 2; 15; 81; 68; 98; 34; 31; 50; 14; 5; 20; 91; 86; 73; 83; 52; 30; 94; 80; 62; 53; 82; 39; 32; 23; 70; 36; 40; 96; 93])
|
| 25 |
+
|
| 26 |
+
let test8 _ = assert_equal 2 (findNonMinOrMax [83; 61; 74; 75; 22; 11; 9; 6; 88; 23; 51; 89; 37; 96; 13; 33; 49; 94; 69; 78; 79; 55; 39; 57; 98; 21; 44; 30; 65; 100; 10; 87; 58; 34; 56; 41; 85; 45; 3; 48; 59; 62; 76; 92; 18; 93; 54; 42; 8; 7; 12; 31; 17; 19; 82; 4; 91; 70; 14; 32; 25; 16; 26; 50; 66; 81; 53; 77; 35; 71; 99; 27; 63; 5; 64; 28; 43; 1; 15; 36; 84; 20; 29; 46; 38; 95; 24; 68; 97; 60; 40])
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
(* Grouping test cases *)
|
| 30 |
+
let suite = "Test Suite for findNonMinOrMax" >::: [
|
| 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
|
neither_minimum_nor_maximum/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.findNonMinOrMax(List(3,2,1,4)), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.findNonMinOrMax(List(1,2)), -1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.findNonMinOrMax(List(2,1,3)), 2)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.findNonMinOrMax(62,86,92,47,22,36,7,99,96,84,43,48,77,41,76,59,29,32,61,26,6,42,19,18,87,24,97,14,65,98,78,72,80,16,91,21,90,94,55,25,50,51,71,5,52,8,53,67,85,56,54,58,79,88,37,11,17,81,74,89,100,23,44,57,35,66,27,20,45,12,39,38), 36)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.findNonMinOrMax(90,66,94,7,88,13), 88)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.findNonMinOrMax(5,64,57,98,72,92,99,12,14,18,85,62,4,77,22,81,36,63,30,55,2,27,35), 57)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.findNonMinOrMax(49,21,100,37,41,38,57,2,15,81,68,98,34,31,50,14,5,20,91,86,73,83,52,30,94,80,62,53,82,39,32,23,70,36,40,96,93), 37)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.findNonMinOrMax(83,61,74,75,22,11,9,6,88,23,51,89,37,96,13,33,49,94,69,78,79,55,39,57,98,21,44,30,65,100,10,87,58,34,56,41,85,45,3,48,59,62,76,92,18,93,54,42,8,7,12,31,17,19,82,4,91,70,14,32,25,16,26,50,66,81,53,77,35,71,99,27,63,5,64,28,43,1,15,36,84,20,29,46,38,95,24,68,97,60,40), 74)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
next_greater_element_iv/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
next_greater_element_iv/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 (secondGreaterElement [2,4,0,9,6])," [9,6,6,-1,-1] (secondGreaterElement [2,4,0,9,6]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (secondGreaterElement [3,3])," [-1,-1] (secondGreaterElement [3,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
|
next_greater_element_iv/java_tests/Main.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(new ArrayList<>(Arrays.asList(9,6,6,-1,-1)), secondGreaterElement(new ArrayList<>(Arrays.asList(2,4,0,9,6))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(new ArrayList<>(Arrays.asList(-1,-1)), secondGreaterElement(new ArrayList<>(Arrays.asList(3,3))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
next_greater_element_iv/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce539d984b887101456ce34ea1b5661a1f2dcf3fd76a839a5aca9ebb2abf3833
|
| 3 |
+
size 23535273
|
next_greater_element_iv/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 [9;6;6;-1;-1] (secondGreaterElement [2;4;0;9;6])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal [-1;-1] (secondGreaterElement [3;3])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for secondGreaterElement" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
next_greater_element_iv/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.secondGreaterElement(List(2,4,0,9,6)), List(9,6,6,-1,-1))
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.secondGreaterElement(List(3,3)), List(-1,-1))
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
node_with_highest_edge_score/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
node_with_highest_edge_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 (edgeScore [1,0,0,0,0,7,7,5])," 7 (edgeScore [1,0,0,0,0,7,7,5]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (edgeScore [2,0,0,2])," 0 (edgeScore [2,0,0,2]))
|
| 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
|
node_with_highest_edge_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(7, edgeScore(new ArrayList<>(Arrays.asList(1,0,0,0,0,7,7,5))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(0, edgeScore(new ArrayList<>(Arrays.asList(2,0,0,2))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
node_with_highest_edge_score/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8239d70cd3b4eaf319ef95808bc3889c92de6973a4ddba83f0dc979f37612add
|
| 3 |
+
size 12886966
|
node_with_highest_edge_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 7 (edgeScore [1;0;0;0;0;7;7;5])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 0 (edgeScore [2;0;0;2])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for edgeScore" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
node_with_highest_edge_score/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.edgeScore(List(1,0,0,0,0,7,7,5)), 7)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.edgeScore(List(2,0,0,2)), 0)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_arithmetic_triplets/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_arithmetic_triplets/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 (arithmeticTriplets [0,1,4,6,7,10] 3)," 2 (arithmeticTriplets [0,1,4,6,7,10] 3))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (arithmeticTriplets [4,5,6,7,8,9] 2)," 2 (arithmeticTriplets [4,5,6,7,8,9] 2))
|
| 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
|
number_of_arithmetic_triplets/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(2, arithmeticTriplets(new ArrayList<>(Arrays.asList(0,1,4,6,7,10)), 3));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, arithmeticTriplets(new ArrayList<>(Arrays.asList(4,5,6,7,8,9)), 2));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
number_of_arithmetic_triplets/meta.json
ADDED
|
@@ -0,0 +1,1015 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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arithmetic-triplets/",
|
| 6 |
+
"date": "1659225600000",
|
| 7 |
+
"task_description": "You are given a **0-indexed**, **strictly increasing** integer array `nums` and a positive integer `diff`. A triplet `(i, j, k)` is an **arithmetic triplet** if the following conditions are met: `i < j < k`, `nums[j] - nums[i] == diff`, and `nums[k] - nums[j] == diff`. Return _the number of unique **arithmetic triplets**._ **Example 1:** ``` **Input:** nums = [0,1,4,6,7,10], diff = 3 **Output:** 2 **Explanation:** (1, 2, 4) is an arithmetic triplet because both 7 - 4 == 3 and 4 - 1 == 3. (2, 4, 5) is an arithmetic triplet because both 10 - 7 == 3 and 7 - 4 == 3. ``` **Example 2:** ``` **Input:** nums = [4,5,6,7,8,9], diff = 2 **Output:** 2 **Explanation:** (0, 2, 4) is an arithmetic triplet because both 8 - 6 == 2 and 6 - 4 == 2. (1, 3, 5) is an arithmetic triplet because both 9 - 7 == 2 and 7 - 5 == 2. ``` **Constraints:** `3 <= nums.length <= 200` `0 <= nums[i] <= 200` `1 <= diff <= 50` `nums` is **strictly** increasing.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [0,1,4,6,7,10], diff = 3",
|
| 12 |
+
"output": "2 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [4,5,6,7,8,9], diff = 2",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
4,
|
| 25 |
+
7,
|
| 26 |
+
13,
|
| 27 |
+
18,
|
| 28 |
+
20,
|
| 29 |
+
27,
|
| 30 |
+
29,
|
| 31 |
+
30,
|
| 32 |
+
42,
|
| 33 |
+
47,
|
| 34 |
+
54,
|
| 35 |
+
57,
|
| 36 |
+
63,
|
| 37 |
+
65,
|
| 38 |
+
66,
|
| 39 |
+
68,
|
| 40 |
+
70,
|
| 41 |
+
83,
|
| 42 |
+
92,
|
| 43 |
+
93,
|
| 44 |
+
95,
|
| 45 |
+
99,
|
| 46 |
+
103,
|
| 47 |
+
117,
|
| 48 |
+
118,
|
| 49 |
+
119,
|
| 50 |
+
120,
|
| 51 |
+
126,
|
| 52 |
+
128,
|
| 53 |
+
136,
|
| 54 |
+
144,
|
| 55 |
+
145,
|
| 56 |
+
154,
|
| 57 |
+
159,
|
| 58 |
+
161,
|
| 59 |
+
164,
|
| 60 |
+
168,
|
| 61 |
+
172,
|
| 62 |
+
174,
|
| 63 |
+
177,
|
| 64 |
+
184,
|
| 65 |
+
187,
|
| 66 |
+
196,
|
| 67 |
+
197,
|
| 68 |
+
198,
|
| 69 |
+
199
|
| 70 |
+
],
|
| 71 |
+
26
|
| 72 |
+
],
|
| 73 |
+
"output": 3
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
[
|
| 78 |
+
0,
|
| 79 |
+
1,
|
| 80 |
+
2,
|
| 81 |
+
5,
|
| 82 |
+
8,
|
| 83 |
+
9,
|
| 84 |
+
10,
|
| 85 |
+
16,
|
| 86 |
+
17,
|
| 87 |
+
18,
|
| 88 |
+
20,
|
| 89 |
+
22,
|
| 90 |
+
23,
|
| 91 |
+
24,
|
| 92 |
+
27,
|
| 93 |
+
28,
|
| 94 |
+
30,
|
| 95 |
+
31,
|
| 96 |
+
32,
|
| 97 |
+
34,
|
| 98 |
+
36,
|
| 99 |
+
38,
|
| 100 |
+
39,
|
| 101 |
+
40,
|
| 102 |
+
41,
|
| 103 |
+
42,
|
| 104 |
+
43,
|
| 105 |
+
44,
|
| 106 |
+
45,
|
| 107 |
+
46,
|
| 108 |
+
47,
|
| 109 |
+
51,
|
| 110 |
+
52,
|
| 111 |
+
53,
|
| 112 |
+
54,
|
| 113 |
+
55,
|
| 114 |
+
57,
|
| 115 |
+
58,
|
| 116 |
+
61,
|
| 117 |
+
64,
|
| 118 |
+
65,
|
| 119 |
+
69,
|
| 120 |
+
72,
|
| 121 |
+
75,
|
| 122 |
+
76,
|
| 123 |
+
80,
|
| 124 |
+
81,
|
| 125 |
+
83,
|
| 126 |
+
85,
|
| 127 |
+
86,
|
| 128 |
+
87,
|
| 129 |
+
88,
|
| 130 |
+
90,
|
| 131 |
+
91,
|
| 132 |
+
92,
|
| 133 |
+
94,
|
| 134 |
+
95,
|
| 135 |
+
101,
|
| 136 |
+
102,
|
| 137 |
+
103,
|
| 138 |
+
104,
|
| 139 |
+
105,
|
| 140 |
+
107,
|
| 141 |
+
108,
|
| 142 |
+
110,
|
| 143 |
+
113,
|
| 144 |
+
114,
|
| 145 |
+
116,
|
| 146 |
+
117,
|
| 147 |
+
119,
|
| 148 |
+
120,
|
| 149 |
+
121,
|
| 150 |
+
122,
|
| 151 |
+
126,
|
| 152 |
+
127,
|
| 153 |
+
128,
|
| 154 |
+
129,
|
| 155 |
+
130,
|
| 156 |
+
132,
|
| 157 |
+
133,
|
| 158 |
+
134,
|
| 159 |
+
135,
|
| 160 |
+
136,
|
| 161 |
+
137,
|
| 162 |
+
138,
|
| 163 |
+
139,
|
| 164 |
+
140,
|
| 165 |
+
142,
|
| 166 |
+
143,
|
| 167 |
+
144,
|
| 168 |
+
146,
|
| 169 |
+
147,
|
| 170 |
+
148,
|
| 171 |
+
149,
|
| 172 |
+
155,
|
| 173 |
+
156,
|
| 174 |
+
157,
|
| 175 |
+
158,
|
| 176 |
+
159,
|
| 177 |
+
160,
|
| 178 |
+
161,
|
| 179 |
+
162,
|
| 180 |
+
163,
|
| 181 |
+
164,
|
| 182 |
+
165,
|
| 183 |
+
166,
|
| 184 |
+
167,
|
| 185 |
+
170,
|
| 186 |
+
171,
|
| 187 |
+
172,
|
| 188 |
+
176,
|
| 189 |
+
177,
|
| 190 |
+
179,
|
| 191 |
+
180,
|
| 192 |
+
182,
|
| 193 |
+
184,
|
| 194 |
+
185,
|
| 195 |
+
186,
|
| 196 |
+
189,
|
| 197 |
+
190,
|
| 198 |
+
193,
|
| 199 |
+
198,
|
| 200 |
+
199
|
| 201 |
+
],
|
| 202 |
+
26
|
| 203 |
+
],
|
| 204 |
+
"output": 39
|
| 205 |
+
},
|
| 206 |
+
{
|
| 207 |
+
"input": [
|
| 208 |
+
[
|
| 209 |
+
0,
|
| 210 |
+
1,
|
| 211 |
+
4,
|
| 212 |
+
5,
|
| 213 |
+
8,
|
| 214 |
+
10,
|
| 215 |
+
11,
|
| 216 |
+
15,
|
| 217 |
+
17,
|
| 218 |
+
20,
|
| 219 |
+
22,
|
| 220 |
+
24,
|
| 221 |
+
26,
|
| 222 |
+
34,
|
| 223 |
+
38,
|
| 224 |
+
45,
|
| 225 |
+
46,
|
| 226 |
+
54,
|
| 227 |
+
55,
|
| 228 |
+
56,
|
| 229 |
+
57,
|
| 230 |
+
58,
|
| 231 |
+
60,
|
| 232 |
+
63,
|
| 233 |
+
65,
|
| 234 |
+
66,
|
| 235 |
+
68,
|
| 236 |
+
74,
|
| 237 |
+
78,
|
| 238 |
+
79,
|
| 239 |
+
86,
|
| 240 |
+
88,
|
| 241 |
+
91,
|
| 242 |
+
92,
|
| 243 |
+
93,
|
| 244 |
+
94,
|
| 245 |
+
95,
|
| 246 |
+
99,
|
| 247 |
+
101,
|
| 248 |
+
104,
|
| 249 |
+
106,
|
| 250 |
+
107,
|
| 251 |
+
113,
|
| 252 |
+
115,
|
| 253 |
+
117,
|
| 254 |
+
118,
|
| 255 |
+
120,
|
| 256 |
+
122,
|
| 257 |
+
123,
|
| 258 |
+
126,
|
| 259 |
+
129,
|
| 260 |
+
130,
|
| 261 |
+
131,
|
| 262 |
+
133,
|
| 263 |
+
137,
|
| 264 |
+
143,
|
| 265 |
+
144,
|
| 266 |
+
152,
|
| 267 |
+
155,
|
| 268 |
+
157,
|
| 269 |
+
158,
|
| 270 |
+
161,
|
| 271 |
+
165,
|
| 272 |
+
166,
|
| 273 |
+
168,
|
| 274 |
+
171,
|
| 275 |
+
175,
|
| 276 |
+
176,
|
| 277 |
+
188,
|
| 278 |
+
189,
|
| 279 |
+
192,
|
| 280 |
+
196,
|
| 281 |
+
197
|
| 282 |
+
],
|
| 283 |
+
17
|
| 284 |
+
],
|
| 285 |
+
"output": 3
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
"input": [
|
| 289 |
+
[
|
| 290 |
+
1,
|
| 291 |
+
2,
|
| 292 |
+
4,
|
| 293 |
+
8,
|
| 294 |
+
9,
|
| 295 |
+
10,
|
| 296 |
+
17,
|
| 297 |
+
18,
|
| 298 |
+
20,
|
| 299 |
+
21,
|
| 300 |
+
23,
|
| 301 |
+
24,
|
| 302 |
+
26,
|
| 303 |
+
27,
|
| 304 |
+
30,
|
| 305 |
+
32,
|
| 306 |
+
33,
|
| 307 |
+
34,
|
| 308 |
+
36,
|
| 309 |
+
38,
|
| 310 |
+
39,
|
| 311 |
+
43,
|
| 312 |
+
55,
|
| 313 |
+
58,
|
| 314 |
+
61,
|
| 315 |
+
66,
|
| 316 |
+
71,
|
| 317 |
+
72,
|
| 318 |
+
73,
|
| 319 |
+
74,
|
| 320 |
+
75,
|
| 321 |
+
76,
|
| 322 |
+
79,
|
| 323 |
+
81,
|
| 324 |
+
82,
|
| 325 |
+
83,
|
| 326 |
+
85,
|
| 327 |
+
86,
|
| 328 |
+
93,
|
| 329 |
+
97,
|
| 330 |
+
99,
|
| 331 |
+
100,
|
| 332 |
+
105,
|
| 333 |
+
107,
|
| 334 |
+
108,
|
| 335 |
+
111,
|
| 336 |
+
115,
|
| 337 |
+
116,
|
| 338 |
+
118,
|
| 339 |
+
121,
|
| 340 |
+
125,
|
| 341 |
+
126,
|
| 342 |
+
129,
|
| 343 |
+
133,
|
| 344 |
+
137,
|
| 345 |
+
141,
|
| 346 |
+
142,
|
| 347 |
+
143,
|
| 348 |
+
144,
|
| 349 |
+
150,
|
| 350 |
+
151,
|
| 351 |
+
153,
|
| 352 |
+
154,
|
| 353 |
+
159,
|
| 354 |
+
163,
|
| 355 |
+
168,
|
| 356 |
+
172,
|
| 357 |
+
174,
|
| 358 |
+
176,
|
| 359 |
+
177,
|
| 360 |
+
178,
|
| 361 |
+
180,
|
| 362 |
+
182,
|
| 363 |
+
183,
|
| 364 |
+
184,
|
| 365 |
+
185,
|
| 366 |
+
186,
|
| 367 |
+
192,
|
| 368 |
+
195,
|
| 369 |
+
196
|
| 370 |
+
],
|
| 371 |
+
39
|
| 372 |
+
],
|
| 373 |
+
"output": 8
|
| 374 |
+
},
|
| 375 |
+
{
|
| 376 |
+
"input": [
|
| 377 |
+
[
|
| 378 |
+
3,
|
| 379 |
+
5,
|
| 380 |
+
7,
|
| 381 |
+
8,
|
| 382 |
+
9,
|
| 383 |
+
10,
|
| 384 |
+
11,
|
| 385 |
+
12,
|
| 386 |
+
13,
|
| 387 |
+
14,
|
| 388 |
+
16,
|
| 389 |
+
18,
|
| 390 |
+
19,
|
| 391 |
+
20,
|
| 392 |
+
24,
|
| 393 |
+
26,
|
| 394 |
+
27,
|
| 395 |
+
28,
|
| 396 |
+
29,
|
| 397 |
+
30,
|
| 398 |
+
34,
|
| 399 |
+
35,
|
| 400 |
+
37,
|
| 401 |
+
38,
|
| 402 |
+
40,
|
| 403 |
+
41,
|
| 404 |
+
42,
|
| 405 |
+
44,
|
| 406 |
+
45,
|
| 407 |
+
46,
|
| 408 |
+
48,
|
| 409 |
+
49,
|
| 410 |
+
50,
|
| 411 |
+
51,
|
| 412 |
+
52,
|
| 413 |
+
53,
|
| 414 |
+
55,
|
| 415 |
+
56,
|
| 416 |
+
61,
|
| 417 |
+
63,
|
| 418 |
+
64,
|
| 419 |
+
66,
|
| 420 |
+
67,
|
| 421 |
+
68,
|
| 422 |
+
70,
|
| 423 |
+
71,
|
| 424 |
+
73,
|
| 425 |
+
75,
|
| 426 |
+
76,
|
| 427 |
+
79,
|
| 428 |
+
80,
|
| 429 |
+
81,
|
| 430 |
+
82,
|
| 431 |
+
83,
|
| 432 |
+
84,
|
| 433 |
+
85,
|
| 434 |
+
86,
|
| 435 |
+
87,
|
| 436 |
+
91,
|
| 437 |
+
93,
|
| 438 |
+
94,
|
| 439 |
+
95,
|
| 440 |
+
97,
|
| 441 |
+
98,
|
| 442 |
+
100,
|
| 443 |
+
101,
|
| 444 |
+
102,
|
| 445 |
+
103,
|
| 446 |
+
104,
|
| 447 |
+
105,
|
| 448 |
+
108,
|
| 449 |
+
110,
|
| 450 |
+
112,
|
| 451 |
+
113,
|
| 452 |
+
114,
|
| 453 |
+
115,
|
| 454 |
+
117,
|
| 455 |
+
119,
|
| 456 |
+
120,
|
| 457 |
+
121,
|
| 458 |
+
122,
|
| 459 |
+
125,
|
| 460 |
+
127,
|
| 461 |
+
128,
|
| 462 |
+
129,
|
| 463 |
+
130,
|
| 464 |
+
131,
|
| 465 |
+
132,
|
| 466 |
+
134,
|
| 467 |
+
136,
|
| 468 |
+
137,
|
| 469 |
+
138,
|
| 470 |
+
144,
|
| 471 |
+
145,
|
| 472 |
+
146,
|
| 473 |
+
147,
|
| 474 |
+
148,
|
| 475 |
+
149,
|
| 476 |
+
150,
|
| 477 |
+
154,
|
| 478 |
+
156,
|
| 479 |
+
158,
|
| 480 |
+
161,
|
| 481 |
+
162,
|
| 482 |
+
164,
|
| 483 |
+
165,
|
| 484 |
+
167,
|
| 485 |
+
168,
|
| 486 |
+
169,
|
| 487 |
+
171,
|
| 488 |
+
173,
|
| 489 |
+
174,
|
| 490 |
+
175,
|
| 491 |
+
176,
|
| 492 |
+
178,
|
| 493 |
+
179,
|
| 494 |
+
182,
|
| 495 |
+
184,
|
| 496 |
+
185,
|
| 497 |
+
186,
|
| 498 |
+
188,
|
| 499 |
+
189,
|
| 500 |
+
190,
|
| 501 |
+
191,
|
| 502 |
+
192,
|
| 503 |
+
193,
|
| 504 |
+
194,
|
| 505 |
+
195,
|
| 506 |
+
196,
|
| 507 |
+
197,
|
| 508 |
+
198,
|
| 509 |
+
200
|
| 510 |
+
],
|
| 511 |
+
8
|
| 512 |
+
],
|
| 513 |
+
"output": 47
|
| 514 |
+
},
|
| 515 |
+
{
|
| 516 |
+
"input": [
|
| 517 |
+
[
|
| 518 |
+
0,
|
| 519 |
+
1,
|
| 520 |
+
3,
|
| 521 |
+
4,
|
| 522 |
+
5,
|
| 523 |
+
6,
|
| 524 |
+
7,
|
| 525 |
+
8,
|
| 526 |
+
9,
|
| 527 |
+
11,
|
| 528 |
+
12,
|
| 529 |
+
13,
|
| 530 |
+
15,
|
| 531 |
+
16,
|
| 532 |
+
17,
|
| 533 |
+
18,
|
| 534 |
+
19,
|
| 535 |
+
20,
|
| 536 |
+
27,
|
| 537 |
+
30,
|
| 538 |
+
32,
|
| 539 |
+
34,
|
| 540 |
+
35,
|
| 541 |
+
36,
|
| 542 |
+
37,
|
| 543 |
+
39,
|
| 544 |
+
43,
|
| 545 |
+
45,
|
| 546 |
+
46,
|
| 547 |
+
47,
|
| 548 |
+
48,
|
| 549 |
+
50,
|
| 550 |
+
51,
|
| 551 |
+
52,
|
| 552 |
+
53,
|
| 553 |
+
55,
|
| 554 |
+
56,
|
| 555 |
+
57,
|
| 556 |
+
58,
|
| 557 |
+
60,
|
| 558 |
+
61,
|
| 559 |
+
62,
|
| 560 |
+
64,
|
| 561 |
+
65,
|
| 562 |
+
66,
|
| 563 |
+
67,
|
| 564 |
+
68,
|
| 565 |
+
69,
|
| 566 |
+
70,
|
| 567 |
+
72,
|
| 568 |
+
73,
|
| 569 |
+
74,
|
| 570 |
+
76,
|
| 571 |
+
77,
|
| 572 |
+
78,
|
| 573 |
+
79,
|
| 574 |
+
80,
|
| 575 |
+
81,
|
| 576 |
+
82,
|
| 577 |
+
83,
|
| 578 |
+
84,
|
| 579 |
+
85,
|
| 580 |
+
86,
|
| 581 |
+
88,
|
| 582 |
+
90,
|
| 583 |
+
91,
|
| 584 |
+
92,
|
| 585 |
+
93,
|
| 586 |
+
95,
|
| 587 |
+
96,
|
| 588 |
+
97,
|
| 589 |
+
98,
|
| 590 |
+
99,
|
| 591 |
+
100,
|
| 592 |
+
101,
|
| 593 |
+
102,
|
| 594 |
+
103,
|
| 595 |
+
105,
|
| 596 |
+
107,
|
| 597 |
+
108,
|
| 598 |
+
110,
|
| 599 |
+
111,
|
| 600 |
+
112,
|
| 601 |
+
113,
|
| 602 |
+
115,
|
| 603 |
+
116,
|
| 604 |
+
117,
|
| 605 |
+
118,
|
| 606 |
+
120,
|
| 607 |
+
121,
|
| 608 |
+
122,
|
| 609 |
+
125,
|
| 610 |
+
127,
|
| 611 |
+
128,
|
| 612 |
+
131,
|
| 613 |
+
132,
|
| 614 |
+
134,
|
| 615 |
+
137,
|
| 616 |
+
138,
|
| 617 |
+
139,
|
| 618 |
+
140,
|
| 619 |
+
141,
|
| 620 |
+
142,
|
| 621 |
+
143,
|
| 622 |
+
145,
|
| 623 |
+
146,
|
| 624 |
+
149,
|
| 625 |
+
152,
|
| 626 |
+
153,
|
| 627 |
+
154,
|
| 628 |
+
155,
|
| 629 |
+
156,
|
| 630 |
+
158,
|
| 631 |
+
160,
|
| 632 |
+
161,
|
| 633 |
+
165,
|
| 634 |
+
167,
|
| 635 |
+
171,
|
| 636 |
+
173,
|
| 637 |
+
174,
|
| 638 |
+
175,
|
| 639 |
+
177,
|
| 640 |
+
178,
|
| 641 |
+
179,
|
| 642 |
+
182,
|
| 643 |
+
183,
|
| 644 |
+
184,
|
| 645 |
+
185,
|
| 646 |
+
187,
|
| 647 |
+
190,
|
| 648 |
+
191,
|
| 649 |
+
194,
|
| 650 |
+
195,
|
| 651 |
+
197
|
| 652 |
+
],
|
| 653 |
+
15
|
| 654 |
+
],
|
| 655 |
+
"output": 61
|
| 656 |
+
},
|
| 657 |
+
{
|
| 658 |
+
"input": [
|
| 659 |
+
[
|
| 660 |
+
4,
|
| 661 |
+
9,
|
| 662 |
+
10,
|
| 663 |
+
13,
|
| 664 |
+
16,
|
| 665 |
+
17,
|
| 666 |
+
18,
|
| 667 |
+
20,
|
| 668 |
+
21,
|
| 669 |
+
22,
|
| 670 |
+
25,
|
| 671 |
+
26,
|
| 672 |
+
27,
|
| 673 |
+
35,
|
| 674 |
+
36,
|
| 675 |
+
41,
|
| 676 |
+
43,
|
| 677 |
+
44,
|
| 678 |
+
47,
|
| 679 |
+
48,
|
| 680 |
+
51,
|
| 681 |
+
52,
|
| 682 |
+
56,
|
| 683 |
+
57,
|
| 684 |
+
64,
|
| 685 |
+
65,
|
| 686 |
+
69,
|
| 687 |
+
71,
|
| 688 |
+
73,
|
| 689 |
+
76,
|
| 690 |
+
78,
|
| 691 |
+
79,
|
| 692 |
+
80,
|
| 693 |
+
81,
|
| 694 |
+
85,
|
| 695 |
+
86,
|
| 696 |
+
87,
|
| 697 |
+
88,
|
| 698 |
+
90,
|
| 699 |
+
91,
|
| 700 |
+
92,
|
| 701 |
+
98,
|
| 702 |
+
101,
|
| 703 |
+
102,
|
| 704 |
+
108,
|
| 705 |
+
109,
|
| 706 |
+
111,
|
| 707 |
+
112,
|
| 708 |
+
113,
|
| 709 |
+
126,
|
| 710 |
+
128,
|
| 711 |
+
129,
|
| 712 |
+
130,
|
| 713 |
+
131,
|
| 714 |
+
133,
|
| 715 |
+
135,
|
| 716 |
+
139,
|
| 717 |
+
141,
|
| 718 |
+
149,
|
| 719 |
+
155,
|
| 720 |
+
156,
|
| 721 |
+
162,
|
| 722 |
+
163,
|
| 723 |
+
164,
|
| 724 |
+
165,
|
| 725 |
+
167,
|
| 726 |
+
168,
|
| 727 |
+
169,
|
| 728 |
+
170,
|
| 729 |
+
172,
|
| 730 |
+
173,
|
| 731 |
+
174,
|
| 732 |
+
175,
|
| 733 |
+
176,
|
| 734 |
+
179,
|
| 735 |
+
182,
|
| 736 |
+
183,
|
| 737 |
+
187,
|
| 738 |
+
191,
|
| 739 |
+
192,
|
| 740 |
+
194,
|
| 741 |
+
195,
|
| 742 |
+
196,
|
| 743 |
+
197,
|
| 744 |
+
198
|
| 745 |
+
],
|
| 746 |
+
6
|
| 747 |
+
],
|
| 748 |
+
"output": 14
|
| 749 |
+
},
|
| 750 |
+
{
|
| 751 |
+
"input": [
|
| 752 |
+
[
|
| 753 |
+
0,
|
| 754 |
+
1,
|
| 755 |
+
2,
|
| 756 |
+
3,
|
| 757 |
+
4,
|
| 758 |
+
5,
|
| 759 |
+
11,
|
| 760 |
+
13,
|
| 761 |
+
15,
|
| 762 |
+
18,
|
| 763 |
+
20,
|
| 764 |
+
22,
|
| 765 |
+
23,
|
| 766 |
+
25,
|
| 767 |
+
26,
|
| 768 |
+
28,
|
| 769 |
+
32,
|
| 770 |
+
34,
|
| 771 |
+
36,
|
| 772 |
+
39,
|
| 773 |
+
41,
|
| 774 |
+
43,
|
| 775 |
+
51,
|
| 776 |
+
52,
|
| 777 |
+
53,
|
| 778 |
+
54,
|
| 779 |
+
55,
|
| 780 |
+
59,
|
| 781 |
+
62,
|
| 782 |
+
69,
|
| 783 |
+
70,
|
| 784 |
+
72,
|
| 785 |
+
76,
|
| 786 |
+
77,
|
| 787 |
+
78,
|
| 788 |
+
81,
|
| 789 |
+
83,
|
| 790 |
+
86,
|
| 791 |
+
89,
|
| 792 |
+
90,
|
| 793 |
+
91,
|
| 794 |
+
94,
|
| 795 |
+
95,
|
| 796 |
+
97,
|
| 797 |
+
98,
|
| 798 |
+
100,
|
| 799 |
+
104,
|
| 800 |
+
108,
|
| 801 |
+
109,
|
| 802 |
+
110,
|
| 803 |
+
111,
|
| 804 |
+
115,
|
| 805 |
+
116,
|
| 806 |
+
119,
|
| 807 |
+
122,
|
| 808 |
+
125,
|
| 809 |
+
126,
|
| 810 |
+
127,
|
| 811 |
+
130,
|
| 812 |
+
132,
|
| 813 |
+
134,
|
| 814 |
+
138,
|
| 815 |
+
139,
|
| 816 |
+
141,
|
| 817 |
+
142,
|
| 818 |
+
148,
|
| 819 |
+
149,
|
| 820 |
+
152,
|
| 821 |
+
153,
|
| 822 |
+
154,
|
| 823 |
+
155,
|
| 824 |
+
158,
|
| 825 |
+
159,
|
| 826 |
+
161,
|
| 827 |
+
162,
|
| 828 |
+
163,
|
| 829 |
+
164,
|
| 830 |
+
167,
|
| 831 |
+
169,
|
| 832 |
+
170,
|
| 833 |
+
175,
|
| 834 |
+
179,
|
| 835 |
+
182,
|
| 836 |
+
184,
|
| 837 |
+
189,
|
| 838 |
+
192,
|
| 839 |
+
193,
|
| 840 |
+
194,
|
| 841 |
+
199,
|
| 842 |
+
200
|
| 843 |
+
],
|
| 844 |
+
6
|
| 845 |
+
],
|
| 846 |
+
"output": 14
|
| 847 |
+
},
|
| 848 |
+
{
|
| 849 |
+
"input": [
|
| 850 |
+
[
|
| 851 |
+
1,
|
| 852 |
+
2,
|
| 853 |
+
6,
|
| 854 |
+
30,
|
| 855 |
+
43,
|
| 856 |
+
47,
|
| 857 |
+
48,
|
| 858 |
+
50,
|
| 859 |
+
52,
|
| 860 |
+
55,
|
| 861 |
+
60,
|
| 862 |
+
63,
|
| 863 |
+
71,
|
| 864 |
+
72,
|
| 865 |
+
78,
|
| 866 |
+
81,
|
| 867 |
+
84,
|
| 868 |
+
87,
|
| 869 |
+
96,
|
| 870 |
+
97,
|
| 871 |
+
117,
|
| 872 |
+
125,
|
| 873 |
+
126,
|
| 874 |
+
137,
|
| 875 |
+
142,
|
| 876 |
+
154,
|
| 877 |
+
167,
|
| 878 |
+
172,
|
| 879 |
+
174,
|
| 880 |
+
178,
|
| 881 |
+
180,
|
| 882 |
+
197,
|
| 883 |
+
200
|
| 884 |
+
],
|
| 885 |
+
20
|
| 886 |
+
],
|
| 887 |
+
"output": 1
|
| 888 |
+
},
|
| 889 |
+
{
|
| 890 |
+
"input": [
|
| 891 |
+
[
|
| 892 |
+
1,
|
| 893 |
+
2,
|
| 894 |
+
5,
|
| 895 |
+
8,
|
| 896 |
+
11,
|
| 897 |
+
12,
|
| 898 |
+
14,
|
| 899 |
+
15,
|
| 900 |
+
17,
|
| 901 |
+
18,
|
| 902 |
+
21,
|
| 903 |
+
23,
|
| 904 |
+
24,
|
| 905 |
+
25,
|
| 906 |
+
26,
|
| 907 |
+
28,
|
| 908 |
+
29,
|
| 909 |
+
32,
|
| 910 |
+
33,
|
| 911 |
+
34,
|
| 912 |
+
35,
|
| 913 |
+
36,
|
| 914 |
+
37,
|
| 915 |
+
38,
|
| 916 |
+
39,
|
| 917 |
+
42,
|
| 918 |
+
48,
|
| 919 |
+
49,
|
| 920 |
+
50,
|
| 921 |
+
51,
|
| 922 |
+
52,
|
| 923 |
+
53,
|
| 924 |
+
55,
|
| 925 |
+
56,
|
| 926 |
+
58,
|
| 927 |
+
61,
|
| 928 |
+
64,
|
| 929 |
+
65,
|
| 930 |
+
66,
|
| 931 |
+
67,
|
| 932 |
+
68,
|
| 933 |
+
69,
|
| 934 |
+
73,
|
| 935 |
+
74,
|
| 936 |
+
75,
|
| 937 |
+
76,
|
| 938 |
+
77,
|
| 939 |
+
82,
|
| 940 |
+
86,
|
| 941 |
+
87,
|
| 942 |
+
90,
|
| 943 |
+
91,
|
| 944 |
+
92,
|
| 945 |
+
93,
|
| 946 |
+
96,
|
| 947 |
+
97,
|
| 948 |
+
100,
|
| 949 |
+
109,
|
| 950 |
+
110,
|
| 951 |
+
111,
|
| 952 |
+
112,
|
| 953 |
+
113,
|
| 954 |
+
118,
|
| 955 |
+
121,
|
| 956 |
+
122,
|
| 957 |
+
123,
|
| 958 |
+
124,
|
| 959 |
+
125,
|
| 960 |
+
126,
|
| 961 |
+
129,
|
| 962 |
+
131,
|
| 963 |
+
132,
|
| 964 |
+
133,
|
| 965 |
+
135,
|
| 966 |
+
136,
|
| 967 |
+
137,
|
| 968 |
+
138,
|
| 969 |
+
141,
|
| 970 |
+
142,
|
| 971 |
+
143,
|
| 972 |
+
146,
|
| 973 |
+
149,
|
| 974 |
+
151,
|
| 975 |
+
152,
|
| 976 |
+
154,
|
| 977 |
+
155,
|
| 978 |
+
158,
|
| 979 |
+
159,
|
| 980 |
+
162,
|
| 981 |
+
163,
|
| 982 |
+
167,
|
| 983 |
+
168,
|
| 984 |
+
169,
|
| 985 |
+
171,
|
| 986 |
+
172,
|
| 987 |
+
175,
|
| 988 |
+
179,
|
| 989 |
+
180,
|
| 990 |
+
182,
|
| 991 |
+
183,
|
| 992 |
+
184,
|
| 993 |
+
185,
|
| 994 |
+
186,
|
| 995 |
+
188,
|
| 996 |
+
190,
|
| 997 |
+
193,
|
| 998 |
+
194,
|
| 999 |
+
195,
|
| 1000 |
+
196,
|
| 1001 |
+
197,
|
| 1002 |
+
199,
|
| 1003 |
+
200
|
| 1004 |
+
],
|
| 1005 |
+
21
|
| 1006 |
+
],
|
| 1007 |
+
"output": 26
|
| 1008 |
+
}
|
| 1009 |
+
],
|
| 1010 |
+
"haskell_template": "arithmeticTriplets :: [Int] -> Int -> Int\narithmeticTriplets nums diff ",
|
| 1011 |
+
"ocaml_template": "let arithmeticTriplets (nums: int list) (diff: int) : int = ",
|
| 1012 |
+
"scala_template": "def arithmeticTriplets(nums: List[Int],diff: Int): Int = { \n \n}",
|
| 1013 |
+
"java_template": "public static int arithmeticTriplets(List<Integer> nums, int diff) {\n\n}",
|
| 1014 |
+
"python_template": "class Solution(object):\n def arithmeticTriplets(self, nums, diff):\n \"\"\"\n :type nums: List[int]\n :type diff: int\n :rtype: int\n \"\"\"\n "
|
| 1015 |
+
}
|
number_of_arithmetic_triplets/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 (arithmeticTriplets [0;1;4;6;7;10] 3)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (arithmeticTriplets [4;5;6;7;8;9] 2)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for arithmeticTriplets" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
number_of_arithmetic_triplets/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.arithmeticTriplets(List(0,1,4,6,7,10),3), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.arithmeticTriplets(List(4,5,6,7,8,9),2), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
number_of_beautiful_pairs/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
countBeautifulPairs :: [Int] -> Int
|
| 7 |
+
countBeautifulPairs nums = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (countBeautifulPairs [2,5,1,4])," 5 (countBeautifulPairs [2,5,1,4]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (countBeautifulPairs [11,21,12])," 2 (countBeautifulPairs [11,21,12]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (countBeautifulPairs [2589, 416, 8132, 718, 9296, 3306, 1258, 8493, 1081, 7335, 9952, 3791, 8418, 3107, 9602, 9979, 4154, 3791, 5243, 4278, 1189, 7207, 4406, 6321, 5226, 7348, 3865, 8301, 9139, 5746, 1283, 8812, 2881, 337, 2335, 8802, 8946, 3125, 744, 905, 5149, 3537, 6498, 6152, 593, 6293, 7359, 1844, 3987, 8635, 9905, 895, 6266, 4775, 2063, 2691, 2218, 2928, 3723, 4926, 3441, 8752, 2078, 909, 2971, 5621, 7526, 6575, 5619, 6609, 7137, 2353, 2725, 986, 1868, 7714, 887, 1386, 1659, 6762, 4999, 4188, 999, 2725, 8302, 8059, 2171, 9442, 5471, 8592, 8029])," 2799 (countBeautifulPairs [2589, 416, 8132, 718, 9296, 3306, 1258, 8493, 1081, 7335, 9952, 3791, 8418, 3107, 9602, 9979, 4154, 3791, 5243, 4278, 1189, 7207, 4406, 6321, 5226, 7348, 3865, 8301, 9139, 5746, 1283, 8812, 2881, 337, 2335, 8802, 8946, 3125, 744, 905, 5149, 3537, 6498, 6152, 593, 6293, 7359, 1844, 3987, 8635, 9905, 895, 6266, 4775, 2063, 2691, 2218, 2928, 3723, 4926, 3441, 8752, 2078, 909, 2971, 5621, 7526, 6575, 5619, 6609, 7137, 2353, 2725, 986, 1868, 7714, 887, 1386, 1659, 6762, 4999, 4188, 999, 2725, 8302, 8059, 2171, 9442, 5471, 8592, 8029]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (countBeautifulPairs [9568, 4468, 6126, 5827, 5061, 3927, 7924, 4233, 9149, 6096, 5542, 183, 1587, 5744, 2683, 2566, 3399, 5854, 2663, 5104, 5289, 8874, 4732, 2438, 1737, 2118, 888, 774, 7576, 9899, 7321, 8013, 5756, 1543, 8629, 6545, 661, 6765, 1825, 4298, 1203, 9153, 3962, 8294, 4541, 1505, 1348, 2182, 4861, 7515, 2859, 7268, 6582, 3294, 263, 8667])," 1093 (countBeautifulPairs [9568, 4468, 6126, 5827, 5061, 3927, 7924, 4233, 9149, 6096, 5542, 183, 1587, 5744, 2683, 2566, 3399, 5854, 2663, 5104, 5289, 8874, 4732, 2438, 1737, 2118, 888, 774, 7576, 9899, 7321, 8013, 5756, 1543, 8629, 6545, 661, 6765, 1825, 4298, 1203, 9153, 3962, 8294, 4541, 1505, 1348, 2182, 4861, 7515, 2859, 7268, 6582, 3294, 263, 8667]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (countBeautifulPairs [189, 1442, 1025, 5855, 2345, 7697, 9091, 8139, 3813, 2638, 9984, 7324, 723, 4521, 9206, 6646, 6567, 1667, 8443, 7935, 6515, 566, 1857, 3678, 1117, 1998, 3079, 1483])," 282 (countBeautifulPairs [189, 1442, 1025, 5855, 2345, 7697, 9091, 8139, 3813, 2638, 9984, 7324, 723, 4521, 9206, 6646, 6567, 1667, 8443, 7935, 6515, 566, 1857, 3678, 1117, 1998, 3079, 1483]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (countBeautifulPairs [653, 7825, 2553, 3689, 7419, 1163, 8588, 239, 405, 4959, 1807, 7928, 3256, 5039, 7751, 1116, 3345, 6622, 1096, 3931, 1107, 3108, 1593, 3615, 2174, 7029, 9643, 2594, 1104, 5459, 1439, 4276, 2173, 8319, 5332, 8338, 9921, 2999, 8215, 3639, 1518, 6172, 4704, 6049, 9599, 1274, 7894, 8023, 1753, 9189, 9743, 6413, 6424, 3327, 3085, 9488, 3903, 6248, 6517, 2345, 8434, 9285, 5527, 7809, 23, 5579])," 1543 (countBeautifulPairs [653, 7825, 2553, 3689, 7419, 1163, 8588, 239, 405, 4959, 1807, 7928, 3256, 5039, 7751, 1116, 3345, 6622, 1096, 3931, 1107, 3108, 1593, 3615, 2174, 7029, 9643, 2594, 1104, 5459, 1439, 4276, 2173, 8319, 5332, 8338, 9921, 2999, 8215, 3639, 1518, 6172, 4704, 6049, 9599, 1274, 7894, 8023, 1753, 9189, 9743, 6413, 6424, 3327, 3085, 9488, 3903, 6248, 6517, 2345, 8434, 9285, 5527, 7809, 23, 5579]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (countBeautifulPairs [8509, 4764, 273, 3519, 5629, 3926, 2559, 6048, 8119, 6751, 3433, 1296, 473, 5707, 449, 5347, 1003, 1078, 9882, 5835, 6132, 8925, 9168, 3645, 9618, 5303, 4033, 2144, 7251, 5381, 3153, 3734, 3081, 3949, 6464, 4827, 6547, 3251, 6987, 3759, 638, 5329, 473, 2389, 1806, 6956, 7795, 7998, 7852, 1614, 2161, 2701, 7735, 6296, 1112, 3958, 251, 1167, 574, 6005, 2636, 2776, 8183, 7834, 3445, 1957, 8008, 6552, 2985, 3612])," 1620 (countBeautifulPairs [8509, 4764, 273, 3519, 5629, 3926, 2559, 6048, 8119, 6751, 3433, 1296, 473, 5707, 449, 5347, 1003, 1078, 9882, 5835, 6132, 8925, 9168, 3645, 9618, 5303, 4033, 2144, 7251, 5381, 3153, 3734, 3081, 3949, 6464, 4827, 6547, 3251, 6987, 3759, 638, 5329, 473, 2389, 1806, 6956, 7795, 7998, 7852, 1614, 2161, 2701, 7735, 6296, 1112, 3958, 251, 1167, 574, 6005, 2636, 2776, 8183, 7834, 3445, 1957, 8008, 6552, 2985, 3612]))
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
-- Grouping test cases
|
| 36 |
+
tests :: Test
|
| 37 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2, TestLabel "Test3" test3, TestLabel "Test4" test4, TestLabel "Test5" test5, TestLabel "Test6" test6]
|
| 38 |
+
|
| 39 |
+
-- Running the tests
|
| 40 |
+
main :: IO Counts
|
| 41 |
+
main = runTestTT tests
|
number_of_beautiful_pairs/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(5, countBeautifulPairs(Arrays.asList(2,5,1,4)));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(2, countBeautifulPairs(Arrays.asList(11,21,12)));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
number_of_beautiful_pairs/meta.json
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
{
|
| 2 |
+
"id": 2831,
|
| 3 |
+
"name": "number_of_beautiful_pairs",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-beautiful-pairs/",
|
| 6 |
+
"date": "2023-06-18 00:00:00",
|
| 7 |
+
"task_description": "You are given a **0-indexed **integer array `nums`. A pair of indices `i`, `j` where `0 <= i < j < nums.length` is called beautiful if the **first digit** of `nums[i]` and the **last digit** of `nums[j]` are **coprime**. Return _the total number of beautiful pairs in _`nums`. Two integers `x` and `y` are **coprime** if there is no integer greater than 1 that divides both of them. In other words, `x` and `y` are coprime if `gcd(x, y) == 1`, where `gcd(x, y)` is the **greatest common divisor** of `x` and `y`. **Example 1:** ``` **Input:** nums = [2,5,1,4] **Output:** 5 **Explanation:** There are 5 beautiful pairs in nums: When i = 0 and j = 1: the first digit of nums[0] is 2, and the last digit of nums[1] is 5. We can confirm that 2 and 5 are coprime, since gcd(2,5) == 1. When i = 0 and j = 2: the first digit of nums[0] is 2, and the last digit of nums[2] is 1. Indeed, gcd(2,1) == 1. When i = 1 and j = 2: the first digit of nums[1] is 5, and the last digit of nums[2] is 1. Indeed, gcd(5,1) == 1. When i = 1 and j = 3: the first digit of nums[1] is 5, and the last digit of nums[3] is 4. Indeed, gcd(5,4) == 1. When i = 2 and j = 3: the first digit of nums[2] is 1, and the last digit of nums[3] is 4. Indeed, gcd(1,4) == 1. Thus, we return 5. ``` **Example 2:** ``` **Input:** nums = [11,21,12] **Output:** 2 **Explanation:** There are 2 beautiful pairs: When i = 0 and j = 1: the first digit of nums[0] is 1, and the last digit of nums[1] is 1. Indeed, gcd(1,1) == 1. When i = 0 and j = 2: the first digit of nums[0] is 1, and the last digit of nums[2] is 2. Indeed, gcd(1,2) == 1. Thus, we return 2. ``` **Constraints:** `2 <= nums.length <= 100` `1 <= nums[i] <= 9999` `nums[i] % 10 != 0`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "nums = [2,5,1,4]",
|
| 12 |
+
"output": "5 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "nums = [11,21,12]",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
2589,
|
| 24 |
+
416,
|
| 25 |
+
8132,
|
| 26 |
+
718,
|
| 27 |
+
9296,
|
| 28 |
+
3306,
|
| 29 |
+
1258,
|
| 30 |
+
8493,
|
| 31 |
+
1081,
|
| 32 |
+
7335,
|
| 33 |
+
9952,
|
| 34 |
+
3791,
|
| 35 |
+
8418,
|
| 36 |
+
3107,
|
| 37 |
+
9602,
|
| 38 |
+
9979,
|
| 39 |
+
4154,
|
| 40 |
+
3791,
|
| 41 |
+
5243,
|
| 42 |
+
4278,
|
| 43 |
+
1189,
|
| 44 |
+
7207,
|
| 45 |
+
4406,
|
| 46 |
+
6321,
|
| 47 |
+
5226,
|
| 48 |
+
7348,
|
| 49 |
+
3865,
|
| 50 |
+
8301,
|
| 51 |
+
9139,
|
| 52 |
+
5746,
|
| 53 |
+
1283,
|
| 54 |
+
8812,
|
| 55 |
+
2881,
|
| 56 |
+
337,
|
| 57 |
+
2335,
|
| 58 |
+
8802,
|
| 59 |
+
8946,
|
| 60 |
+
3125,
|
| 61 |
+
744,
|
| 62 |
+
905,
|
| 63 |
+
5149,
|
| 64 |
+
3537,
|
| 65 |
+
6498,
|
| 66 |
+
6152,
|
| 67 |
+
593,
|
| 68 |
+
6293,
|
| 69 |
+
7359,
|
| 70 |
+
1844,
|
| 71 |
+
3987,
|
| 72 |
+
8635,
|
| 73 |
+
9905,
|
| 74 |
+
895,
|
| 75 |
+
6266,
|
| 76 |
+
4775,
|
| 77 |
+
2063,
|
| 78 |
+
2691,
|
| 79 |
+
2218,
|
| 80 |
+
2928,
|
| 81 |
+
3723,
|
| 82 |
+
4926,
|
| 83 |
+
3441,
|
| 84 |
+
8752,
|
| 85 |
+
2078,
|
| 86 |
+
909,
|
| 87 |
+
2971,
|
| 88 |
+
5621,
|
| 89 |
+
7526,
|
| 90 |
+
6575,
|
| 91 |
+
5619,
|
| 92 |
+
6609,
|
| 93 |
+
7137,
|
| 94 |
+
2353,
|
| 95 |
+
2725,
|
| 96 |
+
986,
|
| 97 |
+
1868,
|
| 98 |
+
7714,
|
| 99 |
+
887,
|
| 100 |
+
1386,
|
| 101 |
+
1659,
|
| 102 |
+
6762,
|
| 103 |
+
4999,
|
| 104 |
+
4188,
|
| 105 |
+
999,
|
| 106 |
+
2725,
|
| 107 |
+
8302,
|
| 108 |
+
8059,
|
| 109 |
+
2171,
|
| 110 |
+
9442,
|
| 111 |
+
5471,
|
| 112 |
+
8592,
|
| 113 |
+
8029
|
| 114 |
+
],
|
| 115 |
+
"output": 2799
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"input": [
|
| 119 |
+
9568,
|
| 120 |
+
4468,
|
| 121 |
+
6126,
|
| 122 |
+
5827,
|
| 123 |
+
5061,
|
| 124 |
+
3927,
|
| 125 |
+
7924,
|
| 126 |
+
4233,
|
| 127 |
+
9149,
|
| 128 |
+
6096,
|
| 129 |
+
5542,
|
| 130 |
+
183,
|
| 131 |
+
1587,
|
| 132 |
+
5744,
|
| 133 |
+
2683,
|
| 134 |
+
2566,
|
| 135 |
+
3399,
|
| 136 |
+
5854,
|
| 137 |
+
2663,
|
| 138 |
+
5104,
|
| 139 |
+
5289,
|
| 140 |
+
8874,
|
| 141 |
+
4732,
|
| 142 |
+
2438,
|
| 143 |
+
1737,
|
| 144 |
+
2118,
|
| 145 |
+
888,
|
| 146 |
+
774,
|
| 147 |
+
7576,
|
| 148 |
+
9899,
|
| 149 |
+
7321,
|
| 150 |
+
8013,
|
| 151 |
+
5756,
|
| 152 |
+
1543,
|
| 153 |
+
8629,
|
| 154 |
+
6545,
|
| 155 |
+
661,
|
| 156 |
+
6765,
|
| 157 |
+
1825,
|
| 158 |
+
4298,
|
| 159 |
+
1203,
|
| 160 |
+
9153,
|
| 161 |
+
3962,
|
| 162 |
+
8294,
|
| 163 |
+
4541,
|
| 164 |
+
1505,
|
| 165 |
+
1348,
|
| 166 |
+
2182,
|
| 167 |
+
4861,
|
| 168 |
+
7515,
|
| 169 |
+
2859,
|
| 170 |
+
7268,
|
| 171 |
+
6582,
|
| 172 |
+
3294,
|
| 173 |
+
263,
|
| 174 |
+
8667
|
| 175 |
+
],
|
| 176 |
+
"output": 1093
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"input": [
|
| 180 |
+
189,
|
| 181 |
+
1442,
|
| 182 |
+
1025,
|
| 183 |
+
5855,
|
| 184 |
+
2345,
|
| 185 |
+
7697,
|
| 186 |
+
9091,
|
| 187 |
+
8139,
|
| 188 |
+
3813,
|
| 189 |
+
2638,
|
| 190 |
+
9984,
|
| 191 |
+
7324,
|
| 192 |
+
723,
|
| 193 |
+
4521,
|
| 194 |
+
9206,
|
| 195 |
+
6646,
|
| 196 |
+
6567,
|
| 197 |
+
1667,
|
| 198 |
+
8443,
|
| 199 |
+
7935,
|
| 200 |
+
6515,
|
| 201 |
+
566,
|
| 202 |
+
1857,
|
| 203 |
+
3678,
|
| 204 |
+
1117,
|
| 205 |
+
1998,
|
| 206 |
+
3079,
|
| 207 |
+
1483
|
| 208 |
+
],
|
| 209 |
+
"output": 282
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"input": [
|
| 213 |
+
653,
|
| 214 |
+
7825,
|
| 215 |
+
2553,
|
| 216 |
+
3689,
|
| 217 |
+
7419,
|
| 218 |
+
1163,
|
| 219 |
+
8588,
|
| 220 |
+
239,
|
| 221 |
+
405,
|
| 222 |
+
4959,
|
| 223 |
+
1807,
|
| 224 |
+
7928,
|
| 225 |
+
3256,
|
| 226 |
+
5039,
|
| 227 |
+
7751,
|
| 228 |
+
1116,
|
| 229 |
+
3345,
|
| 230 |
+
6622,
|
| 231 |
+
1096,
|
| 232 |
+
3931,
|
| 233 |
+
1107,
|
| 234 |
+
3108,
|
| 235 |
+
1593,
|
| 236 |
+
3615,
|
| 237 |
+
2174,
|
| 238 |
+
7029,
|
| 239 |
+
9643,
|
| 240 |
+
2594,
|
| 241 |
+
1104,
|
| 242 |
+
5459,
|
| 243 |
+
1439,
|
| 244 |
+
4276,
|
| 245 |
+
2173,
|
| 246 |
+
8319,
|
| 247 |
+
5332,
|
| 248 |
+
8338,
|
| 249 |
+
9921,
|
| 250 |
+
2999,
|
| 251 |
+
8215,
|
| 252 |
+
3639,
|
| 253 |
+
1518,
|
| 254 |
+
6172,
|
| 255 |
+
4704,
|
| 256 |
+
6049,
|
| 257 |
+
9599,
|
| 258 |
+
1274,
|
| 259 |
+
7894,
|
| 260 |
+
8023,
|
| 261 |
+
1753,
|
| 262 |
+
9189,
|
| 263 |
+
9743,
|
| 264 |
+
6413,
|
| 265 |
+
6424,
|
| 266 |
+
3327,
|
| 267 |
+
3085,
|
| 268 |
+
9488,
|
| 269 |
+
3903,
|
| 270 |
+
6248,
|
| 271 |
+
6517,
|
| 272 |
+
2345,
|
| 273 |
+
8434,
|
| 274 |
+
9285,
|
| 275 |
+
5527,
|
| 276 |
+
7809,
|
| 277 |
+
23,
|
| 278 |
+
5579
|
| 279 |
+
],
|
| 280 |
+
"output": 1543
|
| 281 |
+
},
|
| 282 |
+
{
|
| 283 |
+
"input": [
|
| 284 |
+
8509,
|
| 285 |
+
4764,
|
| 286 |
+
273,
|
| 287 |
+
3519,
|
| 288 |
+
5629,
|
| 289 |
+
3926,
|
| 290 |
+
2559,
|
| 291 |
+
6048,
|
| 292 |
+
8119,
|
| 293 |
+
6751,
|
| 294 |
+
3433,
|
| 295 |
+
1296,
|
| 296 |
+
473,
|
| 297 |
+
5707,
|
| 298 |
+
449,
|
| 299 |
+
5347,
|
| 300 |
+
1003,
|
| 301 |
+
1078,
|
| 302 |
+
9882,
|
| 303 |
+
5835,
|
| 304 |
+
6132,
|
| 305 |
+
8925,
|
| 306 |
+
9168,
|
| 307 |
+
3645,
|
| 308 |
+
9618,
|
| 309 |
+
5303,
|
| 310 |
+
4033,
|
| 311 |
+
2144,
|
| 312 |
+
7251,
|
| 313 |
+
5381,
|
| 314 |
+
3153,
|
| 315 |
+
3734,
|
| 316 |
+
3081,
|
| 317 |
+
3949,
|
| 318 |
+
6464,
|
| 319 |
+
4827,
|
| 320 |
+
6547,
|
| 321 |
+
3251,
|
| 322 |
+
6987,
|
| 323 |
+
3759,
|
| 324 |
+
638,
|
| 325 |
+
5329,
|
| 326 |
+
473,
|
| 327 |
+
2389,
|
| 328 |
+
1806,
|
| 329 |
+
6956,
|
| 330 |
+
7795,
|
| 331 |
+
7998,
|
| 332 |
+
7852,
|
| 333 |
+
1614,
|
| 334 |
+
2161,
|
| 335 |
+
2701,
|
| 336 |
+
7735,
|
| 337 |
+
6296,
|
| 338 |
+
1112,
|
| 339 |
+
3958,
|
| 340 |
+
251,
|
| 341 |
+
1167,
|
| 342 |
+
574,
|
| 343 |
+
6005,
|
| 344 |
+
2636,
|
| 345 |
+
2776,
|
| 346 |
+
8183,
|
| 347 |
+
7834,
|
| 348 |
+
3445,
|
| 349 |
+
1957,
|
| 350 |
+
8008,
|
| 351 |
+
6552,
|
| 352 |
+
2985,
|
| 353 |
+
3612
|
| 354 |
+
],
|
| 355 |
+
"output": 1620
|
| 356 |
+
}
|
| 357 |
+
],
|
| 358 |
+
"haskell_template": "countBeautifulPairs :: [Int] -> Int\ncountBeautifulPairs nums ",
|
| 359 |
+
"ocaml_template": "let countBeautifulPairs (nums: int list) : int = ",
|
| 360 |
+
"scala_template": "def countBeautifulPairs(nums: List[Int]): Int = { \n \n}",
|
| 361 |
+
"java_template": "class Solution {\n public int countBeautifulPairs(int[] nums) {\n \n }\n}",
|
| 362 |
+
"python_template": "class Solution(object):\n def countBeautifulPairs(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n "
|
| 363 |
+
}
|
number_of_beautiful_pairs/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let countBeautifulPairs (nums: int list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 5 (countBeautifulPairs [2;5;1;4])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 2 (countBeautifulPairs [11;21;12])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 2 (countBeautifulPairs [2589; 416; 8132; 718; 9296; 3306; 1258; 8493; 1081; 7335; 9952; 3791; 8418; 3107; 9602; 9979; 4154; 3791; 5243; 4278; 1189; 7207; 4406; 6321; 5226; 7348; 3865; 8301; 9139; 5746; 1283; 8812; 2881; 337; 2335; 8802; 8946; 3125; 744; 905; 5149; 3537; 6498; 6152; 593; 6293; 7359; 1844; 3987; 8635; 9905; 895; 6266; 4775; 2063; 2691; 2218; 2928; 3723; 4926; 3441; 8752; 2078; 909; 2971; 5621; 7526; 6575; 5619; 6609; 7137; 2353; 2725; 986; 1868; 7714; 887; 1386; 1659; 6762; 4999; 4188; 999; 2725; 8302; 8059; 2171; 9442; 5471; 8592; 8029])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 2 (countBeautifulPairs [9568; 4468; 6126; 5827; 5061; 3927; 7924; 4233; 9149; 6096; 5542; 183; 1587; 5744; 2683; 2566; 3399; 5854; 2663; 5104; 5289; 8874; 4732; 2438; 1737; 2118; 888; 774; 7576; 9899; 7321; 8013; 5756; 1543; 8629; 6545; 661; 6765; 1825; 4298; 1203; 9153; 3962; 8294; 4541; 1505; 1348; 2182; 4861; 7515; 2859; 7268; 6582; 3294; 263; 8667])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 2 (countBeautifulPairs [189; 1442; 1025; 5855; 2345; 7697; 9091; 8139; 3813; 2638; 9984; 7324; 723; 4521; 9206; 6646; 6567; 1667; 8443; 7935; 6515; 566; 1857; 3678; 1117; 1998; 3079; 1483])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 2 (countBeautifulPairs [653; 7825; 2553; 3689; 7419; 1163; 8588; 239; 405; 4959; 1807; 7928; 3256; 5039; 7751; 1116; 3345; 6622; 1096; 3931; 1107; 3108; 1593; 3615; 2174; 7029; 9643; 2594; 1104; 5459; 1439; 4276; 2173; 8319; 5332; 8338; 9921; 2999; 8215; 3639; 1518; 6172; 4704; 6049; 9599; 1274; 7894; 8023; 1753; 9189; 9743; 6413; 6424; 3327; 3085; 9488; 3903; 6248; 6517; 2345; 8434; 9285; 5527; 7809; 23; 5579])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 2 (countBeautifulPairs [8509; 4764; 273; 3519; 5629; 3926; 2559; 6048; 8119; 6751; 3433; 1296; 473; 5707; 449; 5347; 1003; 1078; 9882; 5835; 6132; 8925; 9168; 3645; 9618; 5303; 4033; 2144; 7251; 5381; 3153; 3734; 3081; 3949; 6464; 4827; 6547; 3251; 6987; 3759; 638; 5329; 473; 2389; 1806; 6956; 7795; 7998; 7852; 1614; 2161; 2701; 7735; 6296; 1112; 3958; 251; 1167; 574; 6005; 2636; 2776; 8183; 7834; 3445; 1957; 8008; 6552; 2985; 3612])
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Grouping test cases *)
|
| 28 |
+
let suite = "Test Suite for countBeautifulPairs" >::: [
|
| 29 |
+
|
| 30 |
+
"test1" >:: test1;
|
| 31 |
+
"test2" >:: test2;
|
| 32 |
+
"test3" >:: test3;
|
| 33 |
+
"test4" >:: test4;
|
| 34 |
+
"test5" >:: test5;
|
| 35 |
+
"test6" >:: test6;
|
| 36 |
+
"test7" >:: test7;
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
(* Running the tests *)
|
| 41 |
+
let () = run_test_tt_main suite
|
| 42 |
+
end
|
number_of_beautiful_pairs/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.countBeautifulPairs(List(2,5,1,4)), 5)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.countBeautifulPairs(List(11,21,12)), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.countBeautifulPairs(2589,416,8132,718,9296,3306,1258,8493,1081,7335,9952,3791,8418,3107,9602,9979,4154,3791,5243,4278,1189,7207,4406,6321,5226,7348,3865,8301,9139,5746,1283,8812,2881,337,2335,8802,8946,3125,744,905,5149,3537,6498,6152,593,6293,7359,1844,3987,8635,9905,895,6266,4775,2063,2691,2218,2928,3723,4926,3441,8752,2078,909,2971,5621,7526,6575,5619,6609,7137,2353,2725,986,1868,7714,887,1386,1659,6762,4999,4188,999,2725,8302,8059,2171,9442,5471,8592,8029), 2799)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.countBeautifulPairs(9568,4468,6126,5827,5061,3927,7924,4233,9149,6096,5542,183,1587,5744,2683,2566,3399,5854,2663,5104,5289,8874,4732,2438,1737,2118,888,774,7576,9899,7321,8013,5756,1543,8629,6545,661,6765,1825,4298,1203,9153,3962,8294,4541,1505,1348,2182,4861,7515,2859,7268,6582,3294,263,8667), 1093)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.countBeautifulPairs(189,1442,1025,5855,2345,7697,9091,8139,3813,2638,9984,7324,723,4521,9206,6646,6567,1667,8443,7935,6515,566,1857,3678,1117,1998,3079,1483), 282)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.countBeautifulPairs(653,7825,2553,3689,7419,1163,8588,239,405,4959,1807,7928,3256,5039,7751,1116,3345,6622,1096,3931,1107,3108,1593,3615,2174,7029,9643,2594,1104,5459,1439,4276,2173,8319,5332,8338,9921,2999,8215,3639,1518,6172,4704,6049,9599,1274,7894,8023,1753,9189,9743,6413,6424,3327,3085,9488,3903,6248,6517,2345,8434,9285,5527,7809,23,5579), 1543)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.countBeautifulPairs(8509,4764,273,3519,5629,3926,2559,6048,8119,6751,3433,1296,473,5707,449,5347,1003,1078,9882,5835,6132,8925,9168,3645,9618,5303,4033,2144,7251,5381,3153,3734,3081,3949,6464,4827,6547,3251,6987,3759,638,5329,473,2389,1806,6956,7795,7998,7852,1614,2161,2701,7735,6296,1112,3958,251,1167,574,6005,2636,2776,8183,7834,3445,1957,8008,6552,2985,3612), 1620)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
number_of_beautiful_partitions/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
number_of_beautiful_partitions/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 (beautifulPartitions \"23542185131 \" 3 2)," 3 (beautifulPartitions "23542185131" 3 2))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (beautifulPartitions \"23542185131 \" 3 3)," 1 (beautifulPartitions "23542185131" 3 3))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (beautifulPartitions \"3312958 \" 3 1)," 1 (beautifulPartitions "3312958" 3 1))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
-- Grouping test cases
|
| 22 |
+
tests :: Test
|
| 23 |
+
tests = TestList [TestLabel "Test1" test1, TestLabel "Test2" test2]
|
| 24 |
+
|
| 25 |
+
-- Running the tests
|
| 26 |
+
main :: IO Counts
|
| 27 |
+
main = runTestTT tests
|
number_of_beautiful_partitions/java_tests/Main.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import static org.junit.jupiter.api.Assertions.*;
|
| 3 |
+
import org.junit.jupiter.api.Test;
|
| 4 |
+
import java.util.List;
|
| 5 |
+
import java.util.Arrays;
|
| 6 |
+
import java.util.ArrayList;
|
| 7 |
+
public class Main {
|
| 8 |
+
//Program start
|
| 9 |
+
|
| 10 |
+
//Program end
|
| 11 |
+
|
| 12 |
+
@Test
|
| 13 |
+
public void test1() {
|
| 14 |
+
assertEquals(3, beautifulPartitions("23542185131", 3, 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, beautifulPartitions("23542185131", 3, 3));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(1, beautifulPartitions("3312958", 3, 1));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
number_of_beautiful_partitions/meta.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2569,
|
| 3 |
+
"name": "number_of_beautiful_partitions",
|
| 4 |
+
"difficulty": "Hard",
|
| 5 |
+
"link": "https://leetcode.com/problems/number-of-beautiful-partitions/",
|
| 6 |
+
"date": "1668297600000",
|
| 7 |
+
"task_description": "You are given a string `s` that consists of the digits `'1'` to `'9'` and two integers `k` and `minLength`. A partition of `s` is called **beautiful** if: `s` is partitioned into `k` non-intersecting substrings. Each substring has a length of **at least** `minLength`. Each substring starts with a **prime** digit and ends with a **non-prime** digit. Prime digits are `'2'`, `'3'`, `'5'`, and `'7'`, and the rest of the digits are non-prime. Return_ the number of **beautiful** partitions of _`s`. Since the answer may be very large, return it **modulo** `109 + 7`. A **substring** is a contiguous sequence of characters within a string. **Example 1:** ``` **Input:** s = \"23542185131\", k = 3, minLength = 2 **Output:** 3 **Explanation:** There exists three ways to create a beautiful partition: \"2354 | 218 | 5131\" \"2354 | 21851 | 31\" \"2354218 | 51 | 31\" ``` **Example 2:** ``` **Input:** s = \"23542185131\", k = 3, minLength = 3 **Output:** 1 **Explanation:** There exists one way to create a beautiful partition: \"2354 | 218 | 5131\". ``` **Example 3:** ``` **Input:** s = \"3312958\", k = 3, minLength = 1 **Output:** 1 **Explanation:** There exists one way to create a beautiful partition: \"331 | 29 | 58\". ``` **Constraints:** `1 <= k, minLength <= s.length <= 1000` `s` consists of the digits `'1'` to `'9'`.",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "s = \"23542185131\", k = 3, minLength = 2",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "s = \"23542185131\", k = 3, minLength = 3",
|
| 17 |
+
"output": "1 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "s = \"3312958\", k = 3, minLength = 1",
|
| 22 |
+
"output": "1 "
|
| 23 |
+
}
|
| 24 |
+
],
|
| 25 |
+
"private_test_cases": [
|
| 26 |
+
{
|
| 27 |
+
"input": [
|
| 28 |
+
"\"14799179822947387567455836795857273593595986592183174998186383617155757615165219562745715618363564416866256857346664971994581168562161134755327898238989757536575198627339888872545443114569548664476114554614822567193653822772113267248174758776346616361269457898478639729515796948743828638\"",
|
| 29 |
+
99,
|
| 30 |
+
245
|
| 31 |
+
],
|
| 32 |
+
"output": 0
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"input": [
|
| 36 |
+
"\"437413949498186333477426462641925582785215862448125617372236591189521623484143958327529223637565882789426899277231833279\"",
|
| 37 |
+
115,
|
| 38 |
+
10
|
| 39 |
+
],
|
| 40 |
+
"output": 0
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"input": [
|
| 44 |
+
"\"4317464565679651432381413965496285922397668489668864289414635592671162684579677472769267969378545694812183389661351128961842938725173797677572217831772321387499184825854183241997222472419869655463597816493381722557168513874646271199512517977789678214116858557468664331617426249492113964256627394539656557932324391233123995155846379892261542364671395148481322154476251168341752122693179681719275532315973853515946742385986285946536836733546929132869272179899918397699873885484239945613425349893428491566387812141493752433382356485311469983999892834754616362584427525172113116231866779768883659624\"",
|
| 45 |
+
174,
|
| 46 |
+
453
|
| 47 |
+
],
|
| 48 |
+
"output": 0
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"input": [
|
| 52 |
+
"\"752484597635819885466173664323492448318426544719225461993814875643828258657314397983449137779812248721467465214131488167752381573876277\"",
|
| 53 |
+
111,
|
| 54 |
+
65
|
| 55 |
+
],
|
| 56 |
+
"output": 0
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": [
|
| 60 |
+
"\"48359691625839758295964818438679133746447965232248315673424352474779448337347375542985175738951499874873437279656817578173821482974683888288173248661699546629929964986523257417638726347916157525995599861843191277281883946574544211555554478323748483525656185555159255888371637118225814236726819442341127516571966268549383649148839744185125175354986638498386138458956245874881213834795968819149149922947529967921453155853638252655985271148444825774883464755285738733634648424532651335142316473128813271378944262679172686139635762766618627228736156679398158569317485328272362255712775655492558749927867899385288651778697431871859918563373827919321616351261878192938748933359159461513342567817188888591467542994118697566218417583596377369356327137497992633678993143494499881787833848696748519513283588572341353841656366151271631875124172946479491499529811241763158663647783428523421226436826767922459936489874279574589431871757993263986932973697126651956463459339581658145856\"",
|
| 61 |
+
721,
|
| 62 |
+
715
|
| 63 |
+
],
|
| 64 |
+
"output": 0
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"input": [
|
| 68 |
+
"\"161857729969633326821811535419926225618462693999241129297549533741613354959365886839447674342579689415912341157183828996529725545133617189616439214283494612873651824875838628143534238376133511536619681663749371184269791669671789498544421692693889264967711232162234989979657895652186162884219851256934748375553165459348439773818117783649676292665457835285577386682671841931267636821122436437575732188258323835393175829443647514715385268576464578324299743859138397\"",
|
| 69 |
+
44,
|
| 70 |
+
116
|
| 71 |
+
],
|
| 72 |
+
"output": 0
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"input": [
|
| 76 |
+
"536399865312865746346883626876294519957394812233833731842513577957766393183336319162828274794785845734514844964876286757994776477661652762688721211623223779895947338966639188197984529824649453335767694346578872465794867515196633481198517157732651349722625437587553291238694957626222725287493864149564114548734781726711634786883855784792731279128134549185979661894239565376747831958625339688682476245463844686329592637152435914872186542139126377",
|
| 77 |
+
183,
|
| 78 |
+
65
|
| 79 |
+
],
|
| 80 |
+
"output": 0
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"input": [
|
| 84 |
+
"318673251546382596981292699892567635383987323833663734628672772649445225372495264632178416897595573549165787586264455282993176587815647253151815979239453847349868837623822539479837944256766785157616234149611857163676943333258428256589937415638565968699766882379861136459436211549612533623781767249914622992777473257148568616513571553975715735193181388599559786226918446457796857185943843582581175815992988476896385511853343292218426772717723125995547439939225585764131813553444848345697161145274766516219551855943536299359122567541657967543136869134878252234479397966753368324631823194754122242845",
|
| 85 |
+
208,
|
| 86 |
+
113
|
| 87 |
+
],
|
| 88 |
+
"output": 0
|
| 89 |
+
},
|
| 90 |
+
{
|
| 91 |
+
"input": [
|
| 92 |
+
"525993424367234273654971645999936994675566426342215492474724183169338911762181887973113695341239564324314554592221258562558699177437138559743969229517863324918276756373147121685748245655354855416846661188663676343643156539534227411912412634811922563735437282753685119769962718897353692521147994656323966882925912354931643242996199289764826311419319924866352211249715315792332279653518254867329472398672686732682682288426177464742391999165498766735951281381696581591371464372786847559224356635764966875277459123881852635267646656639942318999721741682871139412723261187825253386674573166737882585494983731632729823694149968219895589812486639867186826624341142646383114158368648872957356951177916984959889458975364979479214978495963161236898356999451195815926813381538562538126973265494468464261722495999325829415127857461728632166",
|
| 93 |
+
807,
|
| 94 |
+
167
|
| 95 |
+
],
|
| 96 |
+
"output": 0
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"input": [
|
| 100 |
+
"963821256231166116482823877934857616699335845916597266191655729224666522116975714748144711718399966176218544282298499835735687223436587969163928315918712734938123511143836691868293181539427913115648346479487728662771158652643735998314578795435417223464469713758274986638183187997413357145624368923824329643844622765759556451832897121213983926562168432124216139487848338818281595251458257761987854948752636466976423841134388131117197966323119731427965529297616395817938834717826477749314566322889993287141562798951169373666899838542482273387719317929368385649217545337513194379918529252131581916916424194411946171837877661752886352532894699635259676138493333273476388",
|
| 101 |
+
70,
|
| 102 |
+
253
|
| 103 |
+
],
|
| 104 |
+
"output": 0
|
| 105 |
+
}
|
| 106 |
+
],
|
| 107 |
+
"haskell_template": "beautifulPartitions :: String -> Int -> Int -> Int\nbeautifulPartitions s k minLength ",
|
| 108 |
+
"ocaml_template": "let beautifulPartitions (s: string) (k: int) (minLength: int) : int = ",
|
| 109 |
+
"scala_template": "def beautifulPartitions(s: String,k: Int,minLength: Int): Int = { \n \n}",
|
| 110 |
+
"java_template": "public static int beautifulPartitions(String s, int k, int minLength) {\n\n}",
|
| 111 |
+
"python_template": "class Solution(object):\n def beautifulPartitions(self, s, k, minLength):\n \"\"\"\n :type s: str\n :type k: int\n :type minLength: int\n :rtype: int\n \"\"\"\n "
|
| 112 |
+
}
|