Fastest way to check if a List contains a unique String

前端 未结 10 998
天涯浪人
天涯浪人 2020-12-13 11:43

Basically I have about 1,000,000 strings, for each request I have to check if a String belongs to the list or not.

I\'m worried about the performance, so what\'s the

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 12:30

    With such a huge number of Strings, I immediately think of a Trie. It works better with a more limited set of characters (such as letters) and/or when the start of many string overlap.

提交回复
热议问题