We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
FindKthNumberTest
1 parent e0a1164 commit fa22317Copy full SHA for fa22317
src/test/java/com/thealgorithms/maths/FindKthNumberTest.java
@@ -41,14 +41,14 @@ public void testFindKthMaxInvalidK() {
41
@Test
42
public void testFindKthMaxLargeArray() {
43
int[] array = generateArray(1000);
44
- int k = new Random().nextInt(array.length);
+ int k = new Random().nextInt(1, array.length);
45
int result = FindKthNumber.findKthMax(array, k);
46
Arrays.sort(array);
47
assertEquals(array[array.length - k], result);
48
}
49
50
public static int[] generateArray(int capacity) {
51
- int size = new Random().nextInt(capacity) + 1;
+ int size = new Random().nextInt(2, capacity);
52
int[] array = new int[size];
53
54
for (int i = 0; i < size; i++) {
0 commit comments