Pergunta de entrevista da empresa Intel Corporation

Find k maximum integers in an unsorted array of integers.

Resposta da entrevista

Sigiloso

3 de jun. de 2020

Solution 1: Insert the array into a red-black tree and make a backwards inorder traversal. Solution 2: Transform the array to a maxmium heap and submit k maximum extracts. Solution 3: (I messed it up here, maybe the pressure started to kick in) Copy the array to arraylist, make k linear scans and extract (retrieve and delete) the maximum in each scan. Solution 4: (The most obvious one but it somehow sliped my mind) Sort the array with an efficient sorting algorithem, (heap-sort, quick-sort etc.) and retrieve the last k elements.