One solution is to simply sort the array then return the element k places from the back of the array, resulting in a runtime of O(NLog(N)):

Another solution is to use a binary heap. You can add the numbers to the binary heap, then pop the k largest elements from it. In C++ this is achieved with a priority queue:

This achieves a runtime complexity of O(N) + O(k*log(N)), as popping the top off the heap is O(log(N) itself.