
问题
统计所有小于非负整数 n 的质数的数量。
输入: 10
输出: 4
解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 。
Count the number of prime numbers less than a non-negative number, n.
Input: 10
Output: 4
Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
示例
public class Program { }
以上给出2种算法实现,以下是这个案例的输出结果:
[0,1] [0,1]
分析:
显而易见,TwoSum 的时间复杂度为: ,TwoSum2 的时间复杂度为:
。
本文由 .Net中文网 原创发布,欢迎大家踊跃转载。
转载请注明本文地址:https://www.byteflying.com/archives/3768。