小编nad*_*dir的帖子

Python 将列表转换为集合,大 O

感谢您的帮助

words = [....#Big list of words]
words_set = set(words)
Run Code Online (Sandbox Code Playgroud)

当 n=len(words) 时,我很难确定 set(words) 的复杂性是多少。是 O(n) 因为它在列表的所有项目上移动,还是 O(l(nl)) 当 l 是单个单词长度时?感谢帮助!如果WC和BC之间也有区别的话。

编辑:不要介意 O(l(nl)) ,重复子串大 O 是错误的。

python big-o set asymptotic-complexity python-3.x

6
推荐指数
1
解决办法
4880
查看次数

标签 统计

asymptotic-complexity ×1

big-o ×1

python ×1

python-3.x ×1

set ×1