l******0 发帖数: 244 | 1 Time complexity, the worst case is O(N) for HashMap and O(K), where N is the
number of entries in the map, and K is the length of the input String S.
What about space complexity? 由于 Trie 可以共享字符串,好像要节省存储空间,
看资料说 trie 比 hashmap 更耗空间。为什么? | W***o 发帖数: 6519 | 2 hashmap是array of bag吧
trie的每个node都是一个实体object,占用的字节要多
the
【在 l******0 的大作中提到】 : Time complexity, the worst case is O(N) for HashMap and O(K), where N is the : number of entries in the map, and K is the length of the input String S. : What about space complexity? 由于 Trie 可以共享字符串,好像要节省存储空间, : 看资料说 trie 比 hashmap 更耗空间。为什么?
|
|