Skip to content

Commit 1a4fe22

Browse files
authored
Merge pull request eugenp#5042 from fmm/patch-1
Update FindKthLargest.java
2 parents bfe1429 + b1fd761 commit 1a4fe22

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎algorithms/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public int findKthElementByRandomizedQuickSelect(Integer[] arr, int left, int ri
9898

9999
private int randomPartition(Integer arr[], int left, int right) {
100100
int n = right - left + 1;
101-
int pivot = (int) (Math.random()) % n;
101+
int pivot = (int) (Math.random() * n);
102102
swap(arr, left + pivot, right);
103103
return partition(arr, left, right);
104104
}

0 commit comments

Comments
 (0)