m********l 发帖数: 4394 | 1 How do you merge 2 string lists and remove duplicates. |
S**N 发帖数: 182 | 2 merge, and then sort, and then de-dup?
【在 m********l 的大作中提到】 : How do you merge 2 string lists and remove duplicates.
|
l*****a 发帖数: 14598 | 3 no need to be sorted
just merge,not need to in order,right?
【在 S**N 的大作中提到】 : merge, and then sort, and then de-dup?
|
y*******g 发帖数: 6599 | 4 不sort不要de dup
除非加一个hashtable
【在 l*****a 的大作中提到】 : no need to be sorted : just merge,not need to in order,right?
|
n*******w 发帖数: 687 | 5 sort的代价有点大,O(nlgn )。
比较常规考虑,hashmap其中小的那个string list并且remove dups。然后把大的merge
进来。
如果考虑到hashmap可能overflow,换ties。还不够的话,先用hash function把
string list split到小文件上,然后再用hashmap来remove dups。最后直接合并成大
文件。
进一步,如果容许小概率出错,可以上bloom filter。
【在 m********l 的大作中提到】 : How do you merge 2 string lists and remove duplicates.
|
s********7 发帖数: 4681 | |
g*********s 发帖数: 181 | 7 直接往HashSet 里放不就行了吗?
【在 m********l 的大作中提到】 : How do you merge 2 string lists and remove duplicates.
|