mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
General performance improvement (#6078)
This commit is contained in:
committed by
GitHub
parent
7b962a4a1d
commit
df0c997e4b
@@ -1,5 +1,7 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -10,7 +12,7 @@ public class AllConstructTest {
|
||||
|
||||
@Test
|
||||
public void testAllConstructBasic() {
|
||||
List<List<String>> expected = Arrays.asList(Arrays.asList("he", "l", "l", "o"));
|
||||
List<List<String>> expected = singletonList(Arrays.asList("he", "l", "l", "o"));
|
||||
List<List<String>> result = AllConstruct.allConstruct("hello", Arrays.asList("he", "l", "o"));
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
@@ -24,14 +26,14 @@ public class AllConstructTest {
|
||||
|
||||
@Test
|
||||
public void testAllConstructNoWays() {
|
||||
List<List<String>> expected = Arrays.asList();
|
||||
List<List<String>> expected = emptyList();
|
||||
List<List<String>> result = AllConstruct.allConstruct("abcdef", Arrays.asList("gh", "ijk"));
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllConstructEmptyTarget() {
|
||||
List<List<String>> expected = Arrays.asList(Arrays.asList());
|
||||
List<List<String>> expected = singletonList(emptyList());
|
||||
List<List<String>> result = AllConstruct.allConstruct("", Arrays.asList("a", "b", "c"));
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -23,7 +24,7 @@ public final class AssignmentUsingBitmaskTest {
|
||||
public void testNoPossibleAssignments() {
|
||||
int totalTasks = 3;
|
||||
|
||||
List<List<Integer>> taskPerformed = Arrays.asList(Arrays.asList(2), Arrays.asList(3));
|
||||
List<List<Integer>> taskPerformed = Arrays.asList(singletonList(2), singletonList(3));
|
||||
|
||||
AssignmentUsingBitmask assignment = new AssignmentUsingBitmask(taskPerformed, totalTasks);
|
||||
int ways = assignment.countNoOfWays();
|
||||
@@ -34,7 +35,7 @@ public final class AssignmentUsingBitmaskTest {
|
||||
public void testSinglePersonMultipleTasks() {
|
||||
int totalTasks = 3;
|
||||
|
||||
List<List<Integer>> taskPerformed = Arrays.asList(Arrays.asList(1, 2, 3));
|
||||
List<List<Integer>> taskPerformed = singletonList(Arrays.asList(1, 2, 3));
|
||||
|
||||
AssignmentUsingBitmask assignment = new AssignmentUsingBitmask(taskPerformed, totalTasks);
|
||||
int ways = assignment.countNoOfWays();
|
||||
@@ -45,7 +46,7 @@ public final class AssignmentUsingBitmaskTest {
|
||||
public void testMultiplePeopleSingleTask() {
|
||||
int totalTasks = 1;
|
||||
|
||||
List<List<Integer>> taskPerformed = Arrays.asList(Arrays.asList(1), Arrays.asList(1));
|
||||
List<List<Integer>> taskPerformed = Arrays.asList(singletonList(1), singletonList(1));
|
||||
|
||||
AssignmentUsingBitmask assignment = new AssignmentUsingBitmask(taskPerformed, totalTasks);
|
||||
int ways = assignment.countNoOfWays();
|
||||
|
||||
Reference in New Issue
Block a user