- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathLongestIncreasingSubsequenceNLogNTest.java
22 lines (17 loc) · 1 KB
/
LongestIncreasingSubsequenceNLogNTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
packagecom.thealgorithms.dynamicprogramming;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importjava.util.stream.Stream;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.Arguments;
importorg.junit.jupiter.params.provider.MethodSource;
publicclassLongestIncreasingSubsequenceNLogNTest {
privatestaticStream<Arguments> provideTestCases() {
returnStream.of(Arguments.of(newint[] {10, 9, 2, 5, 3, 7, 101, 18}, 4), Arguments.of(newint[] {0, 1, 0, 3, 2, 3}, 4), Arguments.of(newint[] {7, 7, 7, 7, 7}, 1), Arguments.of(newint[] {1, 3, 5, 4, 7}, 4), Arguments.of(newint[] {}, 0), Arguments.of(newint[] {10}, 1),
Arguments.of(newint[] {3, 10, 2, 1, 20}, 3), Arguments.of(newint[] {50, 3, 10, 7, 40, 80}, 4));
}
@ParameterizedTest
@MethodSource("provideTestCases")
publicvoidtestLengthOfLIS(int[] input, intexpected) {
assertEquals(expected, LongestIncreasingSubsequenceNLogN.lengthOfLIS(input));
}
}