Update FindKthLargest.java

Fix random pivot
This commit is contained in:
Filipe Martins 2018-08-23 08:44:03 -03:00 committed by GitHub
parent e77e8c0025
commit b1fd7611b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -98,7 +98,7 @@ public class FindKthLargest {
private int randomPartition(Integer arr[], int left, int right) {
int n = right - left + 1;
int pivot = (int) (Math.random()) % n;
int pivot = (int) (Math.random() * n);
swap(arr, left + pivot, right);
return partition(arr, left, right);
}