How can we find second maximum from array efficiently?

前端 未结 16 1142
Happy的楠姐
Happy的楠姐 2020-12-25 14:39

Is it possible to find the second maximum number from an array of integers by traversing the array only once?

As an example, I have a array of five integers from whi

16条回答
  •  Happy的楠姐
    2020-12-25 15:02

    Can't we just sort this in decreasing order and take the 2nd element from the sorted array?

提交回复
热议问题