What is the fastest way to sort 1 million integers when integers are from the range [1,100]?

前端 未结 8 1620
慢半拍i
慢半拍i 2020-12-23 22:13

Notes: I\'ve thought about Radix sort, bucket sort, counting sort.

Is there anyway to achieve big O(n)?

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 22:35

    how about just counting the occurrence of each integer and then printing them all. sounds like O(n)

提交回复
热议问题