Pergunta de entrevista da empresa Google

Find the kth largest element in a sorted array.

Respostas da entrevista

Sigiloso

23 de mai. de 2015

The described the algorithm and also wrote some code.

Sigiloso

7 de mar. de 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

Sigiloso

31 de mai. de 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]; }