Write a program to find 100 largest numbers out of an array of 1 billion numbers

前端 未结 30 2153
深忆病人
深忆病人 2020-11-29 14:04

I recently attended an interview where I was asked \"write a program to find 100 largest numbers out of an array of 1 billion numbers.\"

I was only able to give a br

30条回答
  •  死守一世寂寞
    2020-11-29 14:46

    Managing a separate list is extra work and you have to move things around the whole list every time you find another replacement. Just qsort it and take the top 100.

提交回复
热议问题