General performance improvement (#6078)

This commit is contained in:
Strange Developer
2024-11-01 18:52:42 +01:00
committed by GitHub
parent 7b962a4a1d
commit df0c997e4b
29 changed files with 92 additions and 75 deletions

View File

@@ -1,5 +1,6 @@
package com.thealgorithms.maths;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
@@ -27,8 +28,8 @@ public class ChineseRemainderTheoremTest {
@Test
public void testCRTWithSingleCongruence() {
List<Integer> remainders = Arrays.asList(4);
List<Integer> moduli = Arrays.asList(7);
List<Integer> remainders = singletonList(4);
List<Integer> moduli = singletonList(7);
int expected = 4;
int result = ChineseRemainderTheorem.solveCRT(remainders, moduli);
assertEquals(expected, result);

View File

@@ -59,8 +59,7 @@ class MeansTest {
@Test
void geometricMeanMultipleNumbers() {
LinkedList<Double> numbers = new LinkedList<>();
numbers.addAll(Lists.newArrayList(1d, 2d, 3d, 4d, 5d, 6d, 1.25));
LinkedList<Double> numbers = new LinkedList<>(Lists.newArrayList(1d, 2d, 3d, 4d, 5d, 6d, 1.25));
assertEquals(2.6426195539300585, Means.geometric(numbers));
}