Find largest and second largest element in a range

后端 未结 11 2033
情歌与酒
情歌与酒 2020-12-10 07:30

How do I find the above without removing the largest element and searching again? Is there a more efficient way to do this? It does not matter if the these elements are dupl

11条回答
  •  无人及你
    2020-12-10 07:35

    Create a sublist from n..m, sort it descending. Then grab the first two elements. Delete these elements from the orginal list.

提交回复
热议问题