You must log in or register to comment.
Besides the obvious flaws... is that parameter a list named
list
, shadowing thelist()
constructor?you can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1).
you can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful