【发布时间】:2020-07-31 16:56:38
【问题描述】:
http://www.cplusplus.com/reference/unordered_set/unordered_set/find/
对于 unordered_set,在 unordered_set 中查找的时间复杂度平均为常数。 如果我有一个 unordered_set 字符串,那么在该集合中找到一个字符串的时间复杂度是多少? 它会是常数还是 O(字符串的长度)?
【问题讨论】:
-
重点是 cppreference.com 比您链接的来源更准确、更有信誉。
-
是常量还是 O(字符串的长度)? -- 必须计算您要搜索的字符串的哈希值。查看std::hash<std::string> 的实现。
标签: c++ string stl find unordered-set