在无序字符串集中查找字符串的时间复杂度

问题描述 投票:0回答:1

http://www.cplusplus.com/reference/unordered_set/unordered_set/find/

在unordered_set中,find的时间复杂度平均为常数。如果我有一个unordered_set字符串,那么在该集中查找字符串的时间复杂度是多少?它是常量还是O(字符串的长度)?

c++ string stl find unordered-set
1个回答
0
投票
将为O(字符串数)。因为您将目标字符串与每个字符串进行比较。
© www.soinside.com 2019 - 2024. All rights reserved.