duplicates

fun <T> Iterable<T>.duplicates(): Set<T>

Returns the set of elements that occur more than once.

Ordering follows the first repeat occurrence of each element. An empty or duplicate-free receiver yields an empty set.