1
1
12rbah2020-05-14 18:05:48
go
12rbah, 2020-05-14 18:05:48

What is the best algorithm for removing duplicate strings from an array?

I know two ways to remove duplicates (either through a map or a nested loop where everything will go through), are there any other ways to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
uvelichitel, 2020-05-14
@uvelichitel

Bloom filter is faster and lighter than hash-map. Ready-made package - https://github.com/willf/bloom Manually, you can do something like this - https://medium.com/@meeusdylan/creating-a-bloom-fi...

P
Papa, 2020-05-14
Stifflera @PapaStifflera

There is. Sorting the original array of strings and looping in one pass.
https://play.golang.org/p/Sx0sHeixC-s

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question