Amazon interview question

How would you find the second largest integer in an unsorted array? Write the code.

Interview Answer

Anonymous

Oct 17, 2013

Two possibilities:- 1) Sort the area and find the second largest ( using mergsort, nlogn complexity 2) just transverse the array and keep two temporary variables storing the smallest and second smallest.