另一种算法求职面试 [英] Another Algorithm Job-Interview
本文介绍了另一种算法求职面试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,这里的问题:
So here is the question:
假设你有10万的整数取值范围从1到100万。请理清整数。时间复杂度应为O(n)。
Suppose you have 100 thousand integers which ranges from 1 to 1 million. Please sort out the integers. The time complexity should be O(n).
如果谁分享他或她的想法是非常AP preciated。
Anybody who shares his or her ideas is well appreciated.
推荐答案
听起来像是一个简单的计数排序。
Sounds like a straightforward counting sort.
- 后备存储器阵列的尺寸为100万
- 在初始化所有的数组值0
- 通过整数环。对于每一个整数i递增[i]发表之一。
- 通过阵列走并打印每个数字我的[我]次输出排序序列。
空间是恒定的。运行时间为O(n)。
Space is constant. Runtime is O(n).
这篇关于另一种算法求职面试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文