ac370624dbb37c2b82d6fa17b2f5684f2586e27dfa3c1a8dd9a13ce4a4dcb0ba
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +5 -0
- maximum_frequency_of_an_element_after_performing_operations_i/ocaml_tests/main.ml +0 -0
- maximum_frequency_of_an_element_after_performing_operations_i/scala_tests/MySuite.scala +0 -0
- maximum_frequency_of_an_element_after_performing_operations_ii/haskell_tests/Main.hs +0 -0
- maximum_frequency_of_an_element_after_performing_operations_ii/java_tests/Main.java +21 -0
- maximum_frequency_of_an_element_after_performing_operations_ii/meta.json +3 -0
- maximum_frequency_of_an_element_after_performing_operations_ii/ocaml_tests/main.ml +0 -0
- maximum_frequency_of_an_element_after_performing_operations_ii/scala_tests/MySuite.scala +0 -0
- maximum_good_subarray_sum/haskell_tests/Main.hs +0 -0
- maximum_good_subarray_sum/java_tests/Main.java +25 -0
- maximum_good_subarray_sum/meta.json +3 -0
- maximum_good_subarray_sum/ocaml_tests/main.ml +0 -0
- maximum_good_subarray_sum/scala_tests/MySuite.scala +0 -0
- maximum_height_of_a_triangle/haskell_tests/Main.hs +45 -0
- maximum_height_of_a_triangle/java_tests/Main.java +25 -0
- maximum_height_of_a_triangle/meta.json +107 -0
- maximum_height_of_a_triangle/ocaml_tests/main.ml +50 -0
- maximum_height_of_a_triangle/scala_tests/MySuite.scala +44 -0
- maximum_manhattan_distance_after_k_changes/haskell_tests/Main.hs +0 -0
- maximum_manhattan_distance_after_k_changes/java_tests/Main.java +21 -0
- maximum_manhattan_distance_after_k_changes/meta.json +0 -0
- maximum_manhattan_distance_after_k_changes/ocaml_tests/main.ml +0 -0
- maximum_manhattan_distance_after_k_changes/scala_tests/MySuite.scala +0 -0
- maximum_matching_of_players_with_trainers/.DS_Store +0 -0
- maximum_matching_of_players_with_trainers/haskell_tests/Main.hs +24 -0
- maximum_matching_of_players_with_trainers/java_tests/Main.java +21 -0
- maximum_matching_of_players_with_trainers/meta.json +3 -0
- maximum_matching_of_players_with_trainers/ocaml_tests/main.ml +26 -0
- maximum_matching_of_players_with_trainers/scala_tests/MySuite.scala +12 -0
- maximum_number_of_distinct_elements_after_operations/haskell_tests/Main.hs +0 -0
- maximum_number_of_distinct_elements_after_operations/java_tests/Main.java +21 -0
- maximum_number_of_distinct_elements_after_operations/meta.json +0 -0
- maximum_number_of_distinct_elements_after_operations/ocaml_tests/main.ml +0 -0
- maximum_number_of_distinct_elements_after_operations/scala_tests/MySuite.scala +0 -0
- maximum_number_of_fish_in_a_grid/haskell_tests/Main.hs +41 -0
- maximum_number_of_fish_in_a_grid/java_tests/Main.java +20 -0
- maximum_number_of_fish_in_a_grid/meta.json +178 -0
- maximum_number_of_fish_in_a_grid/ocaml_tests/main.ml +42 -0
- maximum_number_of_fish_in_a_grid/scala_tests/MySuite.scala +32 -0
- maximum_number_of_groups_entering_a_competition/.DS_Store +0 -0
- maximum_number_of_groups_entering_a_competition/haskell_tests/Main.hs +24 -0
- maximum_number_of_groups_entering_a_competition/java_tests/Main.java +21 -0
- maximum_number_of_groups_entering_a_competition/meta.json +3 -0
- maximum_number_of_groups_entering_a_competition/ocaml_tests/main.ml +26 -0
- maximum_number_of_groups_entering_a_competition/scala_tests/MySuite.scala +12 -0
- maximum_number_of_groups_with_increasing_length/.DS_Store +0 -0
- maximum_number_of_groups_with_increasing_length/haskell_tests/Main.hs +27 -0
- maximum_number_of_groups_with_increasing_length/java_tests/Main.java +25 -0
- maximum_number_of_groups_with_increasing_length/meta.json +3 -0
- maximum_number_of_groups_with_increasing_length/ocaml_tests/main.ml +29 -0
.gitattributes
CHANGED
|
@@ -175,3 +175,8 @@ maximum_difference_score_in_a_grid/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
| 175 |
maximum_elegance_of_a_k_length_subsequence/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 176 |
maximum_frequency_after_subarray_operation/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 177 |
maximum_frequency_of_an_element_after_performing_operations_i/meta.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
maximum_elegance_of_a_k_length_subsequence/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 176 |
maximum_frequency_after_subarray_operation/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 177 |
maximum_frequency_of_an_element_after_performing_operations_i/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 178 |
+
maximum_frequency_of_an_element_after_performing_operations_ii/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 179 |
+
maximum_good_subarray_sum/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 180 |
+
maximum_matching_of_players_with_trainers/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 181 |
+
maximum_number_of_groups_entering_a_competition/meta.json filter=lfs diff=lfs merge=lfs -text
|
| 182 |
+
maximum_number_of_groups_with_increasing_length/meta.json filter=lfs diff=lfs merge=lfs -text
|
maximum_frequency_of_an_element_after_performing_operations_i/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_frequency_of_an_element_after_performing_operations_i/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_frequency_of_an_element_after_performing_operations_ii/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_frequency_of_an_element_after_performing_operations_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(2, maxFrequency(new ArrayList<>(Arrays.asList(1,4,5)), 1, 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, maxFrequency(new ArrayList<>(Arrays.asList(5,11,20,20)), 5, 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
maximum_frequency_of_an_element_after_performing_operations_ii/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a4d4897f157b4660bc0900c5fd2f064239806f749597350b7d5d59570f115e1
|
| 3 |
+
size 14661167
|
maximum_frequency_of_an_element_after_performing_operations_ii/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_frequency_of_an_element_after_performing_operations_ii/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_good_subarray_sum/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_good_subarray_sum/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(11, maximumSubarraySum(new ArrayList<>(Arrays.asList(1,2,3,4,5,6)), 1));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(11, maximumSubarraySum(new ArrayList<>(Arrays.asList(-1,3,2,4,5)), 3));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(-6, maximumSubarraySum(new ArrayList<>(Arrays.asList(-1,-2,-3,-4)), 2));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
maximum_good_subarray_sum/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e65473865e90be1f1820b59d1a7cc3b38b1e3a0aa08bdd11d553aabf5c498c5
|
| 3 |
+
size 16332598
|
maximum_good_subarray_sum/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_good_subarray_sum/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_height_of_a_triangle/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 (maxHeightOfTriangle 2 4)," 3 (maxHeightOfTriangle 2 4))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maxHeightOfTriangle 2 1)," 2 (maxHeightOfTriangle 2 1))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (maxHeightOfTriangle 10 1)," 2 (maxHeightOfTriangle 10 1))
|
| 19 |
+
|
| 20 |
+
test4 :: Test
|
| 21 |
+
test4 = TestCase (assertEqual "for (maxHeightOfTriangle 23 10)," 6 (maxHeightOfTriangle 23 10))
|
| 22 |
+
|
| 23 |
+
test5 :: Test
|
| 24 |
+
test5 = TestCase (assertEqual "for (maxHeightOfTriangle 7 96)," 5 (maxHeightOfTriangle 7 96))
|
| 25 |
+
|
| 26 |
+
test6 :: Test
|
| 27 |
+
test6 = TestCase (assertEqual "for (maxHeightOfTriangle 60 61)," 14 (maxHeightOfTriangle 60 61))
|
| 28 |
+
|
| 29 |
+
test7 :: Test
|
| 30 |
+
test7 = TestCase (assertEqual "for (maxHeightOfTriangle 68 81)," 16 (maxHeightOfTriangle 68 81))
|
| 31 |
+
|
| 32 |
+
test8 :: Test
|
| 33 |
+
test8 = TestCase (assertEqual "for (maxHeightOfTriangle 49 74)," 14 (maxHeightOfTriangle 49 74))
|
| 34 |
+
|
| 35 |
+
test9 :: Test
|
| 36 |
+
test9 = TestCase (assertEqual "for (maxHeightOfTriangle 71 29)," 10 (maxHeightOfTriangle 71 29))
|
| 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
|
maximum_height_of_a_triangle/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, maxHeightOfTriangle(2, 4));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, maxHeightOfTriangle(2, 1));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(2, maxHeightOfTriangle(10, 1));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
maximum_height_of_a_triangle/meta.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 3469,
|
| 3 |
+
"name": "maximum_height_of_a_triangle",
|
| 4 |
+
"difficulty": "Easy",
|
| 5 |
+
"link": "https://leetcode.com/problems/maximum-height-of-a-triangle/",
|
| 6 |
+
"date": "2024-06-23 00:00:00",
|
| 7 |
+
"task_description": "You are given two integers `red` and `blue` representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on. All the balls in a particular row should be the **same** color, and adjacent rows should have **different** colors. Return the **maximum**_ height of the triangle_ that can be achieved. **Example 1:** **Input:** red = 2, blue = 4 **Output:** 3 **Explanation:** The only possible arrangement is shown above. **Example 2:** **Input:** red = 2, blue = 1 **Output:** 2 **Explanation:** The only possible arrangement is shown above. **Example 3:** **Input:** red = 1, blue = 1 **Output:** 1 **Example 4:** **Input:** red = 10, blue = 1 **Output:** 2 **Explanation:** The only possible arrangement is shown above. **Constraints:** `1 <= red, blue <= 100`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "red = 2, blue = 4",
|
| 12 |
+
"output": "3 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "red = 2, blue = 1",
|
| 17 |
+
"output": "2 "
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"label": "Example 3",
|
| 21 |
+
"input": "red = 1, blue = 1",
|
| 22 |
+
"output": ""
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"label": "Example 4",
|
| 26 |
+
"input": "red = 10, blue = 1",
|
| 27 |
+
"output": "2 "
|
| 28 |
+
}
|
| 29 |
+
],
|
| 30 |
+
"private_test_cases": [
|
| 31 |
+
{
|
| 32 |
+
"input": [
|
| 33 |
+
23,
|
| 34 |
+
10
|
| 35 |
+
],
|
| 36 |
+
"output": 6
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"input": [
|
| 40 |
+
7,
|
| 41 |
+
96
|
| 42 |
+
],
|
| 43 |
+
"output": 5
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"input": [
|
| 47 |
+
60,
|
| 48 |
+
61
|
| 49 |
+
],
|
| 50 |
+
"output": 14
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"input": [
|
| 54 |
+
68,
|
| 55 |
+
81
|
| 56 |
+
],
|
| 57 |
+
"output": 16
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"input": [
|
| 61 |
+
49,
|
| 62 |
+
74
|
| 63 |
+
],
|
| 64 |
+
"output": 14
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"input": [
|
| 68 |
+
71,
|
| 69 |
+
29
|
| 70 |
+
],
|
| 71 |
+
"output": 10
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"input": [
|
| 75 |
+
25,
|
| 76 |
+
5
|
| 77 |
+
],
|
| 78 |
+
"output": 4
|
| 79 |
+
},
|
| 80 |
+
{
|
| 81 |
+
"input": [
|
| 82 |
+
75,
|
| 83 |
+
64
|
| 84 |
+
],
|
| 85 |
+
"output": 16
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"input": [
|
| 89 |
+
50,
|
| 90 |
+
46
|
| 91 |
+
],
|
| 92 |
+
"output": 13
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"input": [
|
| 96 |
+
9,
|
| 97 |
+
16
|
| 98 |
+
],
|
| 99 |
+
"output": 6
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
"haskell_template": "maxHeightOfTriangle :: Int -> Int -> Int\nmaxHeightOfTriangle red blue ",
|
| 103 |
+
"ocaml_template": "let maxHeightOfTriangle (red: int) (blue: int) : int = ",
|
| 104 |
+
"scala_template": "def maxHeightOfTriangle(red: Int,blue: Int): Int = { \n \n}",
|
| 105 |
+
"java_template": "class Solution {\n public int maxHeightOfTriangle(int red, int blue) {\n \n }\n}",
|
| 106 |
+
"python_template": "class Solution(object):\n def maxHeightOfTriangle(self, red, blue):\n \"\"\"\n :type red: int\n :type blue: int\n :rtype: int\n \"\"\"\n "
|
| 107 |
+
}
|
maximum_height_of_a_triangle/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 3 (maxHeightOfTriangle 2 4)
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (maxHeightOfTriangle 2 1)
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 2 (maxHeightOfTriangle 10 1)
|
| 16 |
+
|
| 17 |
+
let test4 _ = assert_equal 6 (maxHeightOfTriangle 23 10)
|
| 18 |
+
|
| 19 |
+
let test5 _ = assert_equal 5 (maxHeightOfTriangle 7 96)
|
| 20 |
+
|
| 21 |
+
let test6 _ = assert_equal 14 (maxHeightOfTriangle 60 61)
|
| 22 |
+
|
| 23 |
+
let test7 _ = assert_equal 16 (maxHeightOfTriangle 68 81)
|
| 24 |
+
|
| 25 |
+
let test8 _ = assert_equal 14 (maxHeightOfTriangle 49 74)
|
| 26 |
+
|
| 27 |
+
let test9 _ = assert_equal 10 (maxHeightOfTriangle 71 29)
|
| 28 |
+
|
| 29 |
+
let test10 _ = assert_equal 4 (maxHeightOfTriangle 25 5)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
(* Grouping test cases *)
|
| 33 |
+
let suite = "Test Suite for maxHeightOfTriangle" >::: [
|
| 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
|
maximum_height_of_a_triangle/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.maxHeightOfTriangle(2,4), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.maxHeightOfTriangle(2,1), 2)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.maxHeightOfTriangle(10,1), 2)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.maxHeightOfTriangle(23,10), 6)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.maxHeightOfTriangle(7,96), 5)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.maxHeightOfTriangle(60,61), 14)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.maxHeightOfTriangle(68,81), 16)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
test("test8") {
|
| 33 |
+
assertEquals(Main.maxHeightOfTriangle(49,74), 14)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
test("test9") {
|
| 37 |
+
assertEquals(Main.maxHeightOfTriangle(71,29), 10)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
test("test10") {
|
| 41 |
+
assertEquals(Main.maxHeightOfTriangle(25,5), 4)
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
}
|
maximum_manhattan_distance_after_k_changes/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_manhattan_distance_after_k_changes/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(3, maxDistance("NWSE", 1));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(6, maxDistance("NSWWEW", 3));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
maximum_manhattan_distance_after_k_changes/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_manhattan_distance_after_k_changes/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_manhattan_distance_after_k_changes/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_matching_of_players_with_trainers/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
maximum_matching_of_players_with_trainers/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 (matchPlayersAndTrainers [4,7,9] [8,2,5,8])," 2 (matchPlayersAndTrainers [4,7,9] [8,2,5,8]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (matchPlayersAndTrainers [1,1,1] [10])," 1 (matchPlayersAndTrainers [1,1,1] [10]))
|
| 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
|
maximum_matching_of_players_with_trainers/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, matchPlayersAndTrainers(new ArrayList<>(Arrays.asList(4,7,9)), new ArrayList<>(Arrays.asList(8,2,5,8))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, matchPlayersAndTrainers(new ArrayList<>(Arrays.asList(1,1,1)), new ArrayList<>(Arrays.asList(10))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
maximum_matching_of_players_with_trainers/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:edbc413c4aa23235b3f23f12161d48418db69e519fd1e4a8b300c927335040c2
|
| 3 |
+
size 25445937
|
maximum_matching_of_players_with_trainers/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 (matchPlayersAndTrainers [4;7;9] [8;2;5;8])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (matchPlayersAndTrainers [1;1;1] [10])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for matchPlayersAndTrainers" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
maximum_matching_of_players_with_trainers/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.matchPlayersAndTrainers(List(4,7,9),List(8,2,5,8)), 2)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.matchPlayersAndTrainers(List(1,1,1),List(10)), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
maximum_number_of_distinct_elements_after_operations/haskell_tests/Main.hs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_number_of_distinct_elements_after_operations/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(6, maxDistinctElements(new ArrayList<>(Arrays.asList(1,2,2,3,3,4)), 2));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(3, maxDistinctElements(new ArrayList<>(Arrays.asList(4,4,4,4)), 1));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
maximum_number_of_distinct_elements_after_operations/meta.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_number_of_distinct_elements_after_operations/ocaml_tests/main.ml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_number_of_distinct_elements_after_operations/scala_tests/MySuite.scala
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
maximum_number_of_fish_in_a_grid/haskell_tests/Main.hs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main where
|
| 3 |
+
import Test.HUnit
|
| 4 |
+
|
| 5 |
+
--Program start
|
| 6 |
+
findMaxFish :: [[Int]] -> Int
|
| 7 |
+
findMaxFish grid = undefined
|
| 8 |
+
|
| 9 |
+
--Program end
|
| 10 |
+
|
| 11 |
+
-- Test cases
|
| 12 |
+
|
| 13 |
+
test1 :: Test
|
| 14 |
+
test1 = TestCase (assertEqual "for (findMaxFish [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]])," 7 (findMaxFish [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]]))
|
| 15 |
+
|
| 16 |
+
test2 :: Test
|
| 17 |
+
test2 = TestCase (assertEqual "for (findMaxFish [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]])," 1 (findMaxFish [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]]))
|
| 18 |
+
|
| 19 |
+
test3 :: Test
|
| 20 |
+
test3 = TestCase (assertEqual "for (findMaxFish [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]])," 85 (findMaxFish [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]))
|
| 21 |
+
|
| 22 |
+
test4 :: Test
|
| 23 |
+
test4 = TestCase (assertEqual "for (findMaxFish [[0, 0, 0, 0], [0, 0, 0, 0]])," 37 (findMaxFish [[0, 0, 0, 0], [0, 0, 0, 0]]))
|
| 24 |
+
|
| 25 |
+
test5 :: Test
|
| 26 |
+
test5 = TestCase (assertEqual "for (findMaxFish [[0, 0, 0, 0, 0, 0]])," 35 (findMaxFish [[0, 0, 0, 0, 0, 0]]))
|
| 27 |
+
|
| 28 |
+
test6 :: Test
|
| 29 |
+
test6 = TestCase (assertEqual "for (findMaxFish [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])," 196 (findMaxFish [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]))
|
| 30 |
+
|
| 31 |
+
test7 :: Test
|
| 32 |
+
test7 = TestCase (assertEqual "for (findMaxFish [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]])," 68 (findMaxFish [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]))
|
| 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
|
maximum_number_of_fish_in_a_grid/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(7, findMaxFish(Arrays.asList(Arrays.asList(0,2,1,0),Arrays.asList(4,0,0,3),Arrays.asList(1,0,0,4),Arrays.asList(0,3,2,0))));
|
| 14 |
+
}
|
| 15 |
+
@Test
|
| 16 |
+
public void test2() {
|
| 17 |
+
assertEquals(1, findMaxFish(Arrays.asList(Arrays.asList(1,0,0,0),Arrays.asList(0,0,0,0),Arrays.asList(0,0,0,0),Arrays.asList(0,0,0,1))));
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
maximum_number_of_fish_in_a_grid/meta.json
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": 2764,
|
| 3 |
+
"name": "maximum_number_of_fish_in_a_grid",
|
| 4 |
+
"difficulty": "Medium",
|
| 5 |
+
"link": "https://leetcode.com/problems/maximum-number-of-fish-in-a-grid/",
|
| 6 |
+
"date": "2023-04-15 00:00:00",
|
| 7 |
+
"task_description": "You are given a **0-indexed** 2D matrix `grid` of size `m x n`, where `(r, c)` represents: A **land** cell if `grid[r][c] = 0`, or A **water** cell containing `grid[r][c]` fish, if `grid[r][c] > 0`. A fisher can start at any **water** cell `(r, c)` and can do the following operations any number of times: Catch all the fish at cell `(r, c)`, or Move to any adjacent **water** cell. Return _the **maximum** number of fish the fisher can catch if he chooses his starting cell optimally, or _`0` if no water cell exists. An **adjacent** cell of the cell `(r, c)`, is one of the cells `(r, c + 1)`, `(r, c - 1)`, `(r + 1, c)` or `(r - 1, c)` if it exists. **Example 1:** ``` **Input:** grid = [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]] **Output:** 7 **Explanation:** The fisher can start at cell `(1,3)` and collect 3 fish, then move to cell `(2,3)` and collect 4 fish. ``` **Example 2:** ``` **Input:** grid = [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]] **Output:** 1 **Explanation:** The fisher can start at cells (0,0) or (3,3) and collect a single fish. ``` **Constraints:** `m == grid.length` `n == grid[i].length` `1 <= m, n <= 10` `0 <= grid[i][j] <= 10`",
|
| 8 |
+
"public_test_cases": [
|
| 9 |
+
{
|
| 10 |
+
"label": "Example 1",
|
| 11 |
+
"input": "grid = [[0,2,1,0],[4,0,0,3],[1,0,0,4],[0,3,2,0]]",
|
| 12 |
+
"output": "7 "
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"label": "Example 2",
|
| 16 |
+
"input": "grid = [[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,1]]",
|
| 17 |
+
"output": "1 "
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
"private_test_cases": [
|
| 21 |
+
{
|
| 22 |
+
"input": [
|
| 23 |
+
[
|
| 24 |
+
0,
|
| 25 |
+
0
|
| 26 |
+
],
|
| 27 |
+
[
|
| 28 |
+
0,
|
| 29 |
+
0
|
| 30 |
+
],
|
| 31 |
+
[
|
| 32 |
+
0,
|
| 33 |
+
0
|
| 34 |
+
],
|
| 35 |
+
[
|
| 36 |
+
0,
|
| 37 |
+
0
|
| 38 |
+
],
|
| 39 |
+
[
|
| 40 |
+
0,
|
| 41 |
+
0
|
| 42 |
+
],
|
| 43 |
+
[
|
| 44 |
+
0,
|
| 45 |
+
0
|
| 46 |
+
],
|
| 47 |
+
[
|
| 48 |
+
0,
|
| 49 |
+
0
|
| 50 |
+
],
|
| 51 |
+
[
|
| 52 |
+
0,
|
| 53 |
+
0
|
| 54 |
+
]
|
| 55 |
+
],
|
| 56 |
+
"output": 85
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"input": [
|
| 60 |
+
[
|
| 61 |
+
0,
|
| 62 |
+
0,
|
| 63 |
+
0,
|
| 64 |
+
0
|
| 65 |
+
],
|
| 66 |
+
[
|
| 67 |
+
0,
|
| 68 |
+
0,
|
| 69 |
+
0,
|
| 70 |
+
0
|
| 71 |
+
]
|
| 72 |
+
],
|
| 73 |
+
"output": 37
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"input": [
|
| 77 |
+
[
|
| 78 |
+
0,
|
| 79 |
+
0,
|
| 80 |
+
0,
|
| 81 |
+
0,
|
| 82 |
+
0,
|
| 83 |
+
0
|
| 84 |
+
]
|
| 85 |
+
],
|
| 86 |
+
"output": 35
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"input": [
|
| 90 |
+
[
|
| 91 |
+
0,
|
| 92 |
+
0,
|
| 93 |
+
0,
|
| 94 |
+
0
|
| 95 |
+
],
|
| 96 |
+
[
|
| 97 |
+
0,
|
| 98 |
+
0,
|
| 99 |
+
0,
|
| 100 |
+
0
|
| 101 |
+
],
|
| 102 |
+
[
|
| 103 |
+
0,
|
| 104 |
+
0,
|
| 105 |
+
0,
|
| 106 |
+
0
|
| 107 |
+
],
|
| 108 |
+
[
|
| 109 |
+
0,
|
| 110 |
+
0,
|
| 111 |
+
0,
|
| 112 |
+
0
|
| 113 |
+
],
|
| 114 |
+
[
|
| 115 |
+
0,
|
| 116 |
+
0,
|
| 117 |
+
0,
|
| 118 |
+
0
|
| 119 |
+
],
|
| 120 |
+
[
|
| 121 |
+
0,
|
| 122 |
+
0,
|
| 123 |
+
0,
|
| 124 |
+
0
|
| 125 |
+
],
|
| 126 |
+
[
|
| 127 |
+
0,
|
| 128 |
+
0,
|
| 129 |
+
0,
|
| 130 |
+
0
|
| 131 |
+
],
|
| 132 |
+
[
|
| 133 |
+
0,
|
| 134 |
+
0,
|
| 135 |
+
0,
|
| 136 |
+
0
|
| 137 |
+
],
|
| 138 |
+
[
|
| 139 |
+
0,
|
| 140 |
+
0,
|
| 141 |
+
0,
|
| 142 |
+
0
|
| 143 |
+
]
|
| 144 |
+
],
|
| 145 |
+
"output": 196
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"input": [
|
| 149 |
+
[
|
| 150 |
+
0,
|
| 151 |
+
0,
|
| 152 |
+
0
|
| 153 |
+
],
|
| 154 |
+
[
|
| 155 |
+
0,
|
| 156 |
+
0,
|
| 157 |
+
0
|
| 158 |
+
],
|
| 159 |
+
[
|
| 160 |
+
0,
|
| 161 |
+
0,
|
| 162 |
+
0
|
| 163 |
+
],
|
| 164 |
+
[
|
| 165 |
+
0,
|
| 166 |
+
0,
|
| 167 |
+
0
|
| 168 |
+
]
|
| 169 |
+
],
|
| 170 |
+
"output": 68
|
| 171 |
+
}
|
| 172 |
+
],
|
| 173 |
+
"haskell_template": "findMaxFish :: [[Int]] -> Int\nfindMaxFish grid ",
|
| 174 |
+
"ocaml_template": "let findMaxFish (grid: int list list) : int = ",
|
| 175 |
+
"scala_template": "def findMaxFish(grid: List[List[Int]]): Int = { \n \n}",
|
| 176 |
+
"java_template": "class Solution {\n public int findMaxFish(int[][] grid) {\n \n }\n}",
|
| 177 |
+
"python_template": "class Solution(object):\n def findMaxFish(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: int\n \"\"\"\n "
|
| 178 |
+
}
|
maximum_number_of_fish_in_a_grid/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
let findMaxFish (grid: int list list) : int = failwith "Not implemented"
|
| 7 |
+
|
| 8 |
+
(* Program end *)
|
| 9 |
+
|
| 10 |
+
(* Test cases *)
|
| 11 |
+
|
| 12 |
+
let test1 _ = assert_equal 7 (findMaxFish [[0;2;1;0];[4;0;0;3];[1;0;0;4];[0;3;2;0]])
|
| 13 |
+
|
| 14 |
+
let test2 _ = assert_equal 1 (findMaxFish [[1;0;0;0];[0;0;0;0];[0;0;0;0];[0;0;0;1]])
|
| 15 |
+
|
| 16 |
+
let test3 _ = assert_equal 1 (findMaxFish [[0; 0]; [0; 0]; [0; 0]; [0; 0]; [0; 0]; [0; 0]; [0; 0]; [0; 0]])
|
| 17 |
+
|
| 18 |
+
let test4 _ = assert_equal 1 (findMaxFish [[0; 0; 0; 0]; [0; 0; 0; 0]])
|
| 19 |
+
|
| 20 |
+
let test5 _ = assert_equal 1 (findMaxFish [[0; 0; 0; 0; 0; 0]])
|
| 21 |
+
|
| 22 |
+
let test6 _ = assert_equal 1 (findMaxFish [[0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]; [0; 0; 0; 0]])
|
| 23 |
+
|
| 24 |
+
let test7 _ = assert_equal 1 (findMaxFish [[0; 0; 0]; [0; 0; 0]; [0; 0; 0]; [0; 0; 0]])
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
(* Grouping test cases *)
|
| 28 |
+
let suite = "Test Suite for findMaxFish" >::: [
|
| 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
|
maximum_number_of_fish_in_a_grid/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.findMaxFish(List(List(0,2,1,0),List(4,0,0,3),List(1,0,0,4),List(0,3,2,0))), 7)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.findMaxFish(List(List(1,0,0,0),List(0,0,0,0),List(0,0,0,0),List(0,0,0,1))), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
test("test3") {
|
| 13 |
+
assertEquals(Main.findMaxFish(List(0, 0),List(0, 0),List(0, 0),List(0, 0),List(0, 0),List(0, 0),List(0, 0),List(0, 0)), 85)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
test("test4") {
|
| 17 |
+
assertEquals(Main.findMaxFish(List(0, 0, 0, 0),List(0, 0, 0, 0)), 37)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
test("test5") {
|
| 21 |
+
assertEquals(Main.findMaxFish(List(0, 0, 0, 0, 0, 0)), 35)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
test("test6") {
|
| 25 |
+
assertEquals(Main.findMaxFish(List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0),List(0, 0, 0, 0)), 196)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
test("test7") {
|
| 29 |
+
assertEquals(Main.findMaxFish(List(0, 0, 0),List(0, 0, 0),List(0, 0, 0),List(0, 0, 0)), 68)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
maximum_number_of_groups_entering_a_competition/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
maximum_number_of_groups_entering_a_competition/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 (maximumGroups [10,6,12,7,3,5])," 3 (maximumGroups [10,6,12,7,3,5]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maximumGroups [8,8])," 1 (maximumGroups [8,8]))
|
| 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
|
maximum_number_of_groups_entering_a_competition/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(3, maximumGroups(new ArrayList<>(Arrays.asList(10,6,12,7,3,5))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(1, maximumGroups(new ArrayList<>(Arrays.asList(8,8))));
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
maximum_number_of_groups_entering_a_competition/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8eeba3580a4987ff868cfa42e89f50f95e348564f394ba8b3f9efbc3c7c0f3f6
|
| 3 |
+
size 10902205
|
maximum_number_of_groups_entering_a_competition/ocaml_tests/main.ml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
module Main = struct
|
| 3 |
+
open OUnit2
|
| 4 |
+
|
| 5 |
+
(* Program start *)
|
| 6 |
+
|
| 7 |
+
(* Program end *)
|
| 8 |
+
|
| 9 |
+
(* Test cases *)
|
| 10 |
+
|
| 11 |
+
let test1 _ = assert_equal 3 (maximumGroups [10;6;12;7;3;5])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 1 (maximumGroups [8;8])
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
(* Grouping test cases *)
|
| 17 |
+
let suite = "Test Suite for maximumGroups" >::: [
|
| 18 |
+
|
| 19 |
+
"test1" >:: test1;
|
| 20 |
+
"test2" >:: test2;
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
(* Running the tests *)
|
| 25 |
+
let () = run_test_tt_main suite
|
| 26 |
+
end
|
maximum_number_of_groups_entering_a_competition/scala_tests/MySuite.scala
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
class MySuite extends munit.FunSuite {
|
| 3 |
+
|
| 4 |
+
test("test1") {
|
| 5 |
+
assertEquals(Main.maximumGroups(List(10,6,12,7,3,5)), 3)
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
test("test2") {
|
| 9 |
+
assertEquals(Main.maximumGroups(List(8,8)), 1)
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
}
|
maximum_number_of_groups_with_increasing_length/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
maximum_number_of_groups_with_increasing_length/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 (maxIncreasingGroups [1,2,5])," 3 (maxIncreasingGroups [1,2,5]))
|
| 13 |
+
|
| 14 |
+
test2 :: Test
|
| 15 |
+
test2 = TestCase (assertEqual "for (maxIncreasingGroups [2,1,2])," 2 (maxIncreasingGroups [2,1,2]))
|
| 16 |
+
|
| 17 |
+
test3 :: Test
|
| 18 |
+
test3 = TestCase (assertEqual "for (maxIncreasingGroups [1,1])," 1 (maxIncreasingGroups [1,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
|
maximum_number_of_groups_with_increasing_length/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, maxIncreasingGroups(new ArrayList<>(Arrays.asList(1,2,5))));
|
| 15 |
+
}
|
| 16 |
+
@Test
|
| 17 |
+
public void test2() {
|
| 18 |
+
assertEquals(2, maxIncreasingGroups(new ArrayList<>(Arrays.asList(2,1,2))));
|
| 19 |
+
}
|
| 20 |
+
@Test
|
| 21 |
+
public void test3() {
|
| 22 |
+
assertEquals(1, maxIncreasingGroups(new ArrayList<>(Arrays.asList(1,1))));
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
maximum_number_of_groups_with_increasing_length/meta.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1cd77833859a9b5420ceb1b715a7b33fd233fd4cb614a43520abecadbd0d4d73
|
| 3 |
+
size 12386556
|
maximum_number_of_groups_with_increasing_length/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 3 (maxIncreasingGroups [1;2;5])
|
| 12 |
+
|
| 13 |
+
let test2 _ = assert_equal 2 (maxIncreasingGroups [2;1;2])
|
| 14 |
+
|
| 15 |
+
let test3 _ = assert_equal 1 (maxIncreasingGroups [1;1])
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
(* Grouping test cases *)
|
| 19 |
+
let suite = "Test Suite for maxIncreasingGroups" >::: [
|
| 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
|