Category
The iterable to find duplicates in
An array of the duplicated elements
Iterable
Using frequencyTable to get the number of times each element was duplicated
frequencyTable(allDuplicates([1, 2, 2, 2, 3, 3])); // Map(2) { 2 => 2, 3 => 1 }
duplicates to receive a Set
of duplicate elements instead of an array (which can include the same element more than once)
Get an array of all the duplicate elements in an iterable.
Time complexity: O(n)
Space complexity: O(n)