Some languages have built-in types for sets.

In Go a best practice is to use a map of a desired type with values of type struct{} because a map with values of empty struct is especially optimized.

For example, a set of strings:

https://codeeval.dev/gist/2f0f3ca37296cade012f22c52b28547a