1). If we try to sort array by comparison based sorting ,,then it will take O(nlogn).
Then , finding minimum or maximum can be done in O(1).
2). Now, see procedure by a heap. Try to insert all these elements in max heap , it can be done
in O(nlogn), but if you efficiently use it, can be done in O(n) time . Now, we can get maximum in
O(1) time and if you want to extract it , then takes O(logn).
Hence, total complexity is O(n + logn) .
3). simple linear scan also will give O(n) .
So, finally best efficient complexity will be O(n) .