问题标签 [iterated-logarithm]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
403 浏览

python - Python中“set”和“if item in array”的时间复杂度是多少?

我需要检查一个数字及其双精度数是否存在于数组中。这段代码set用来解决它。但是我不确定时间复杂度是否优于O(N^2). 我使用下面的for loopand if 2*item in s。不是要知道item是否在数组中,我们用另一个O(N)。总共是什么意思O(N^2)?如果它是最佳的,我如何在不使用的情况下实现 C 中的代码nested loop
非常感谢!