Pregunta de entrevista de Google

Find the kth largest element in a sorted array.

Respuestas de entrevistas

Anónimo

23 may 2015

The described the algorithm and also wrote some code.

Anónimo

7 mar 2016

Your solution wouldn't work if the array as duplicate. {1,2,3,3,4,5,5,6} k = 2 result should be 5

Anónimo

31 may 2015

If the array is already sorted, can't you just return n-k element? public static int kthLargest(int [] array), int k { if (array.length == 0 || k > array.length) { throw new llegalArgumentException(); } return array[ array.length - k]; }