I have to filter an array having the most occurrences of element.
Initial Array :
let array1 = [1,2,3,2,4,2,5,3]
let array2 = ["abc", "def", "abc", "ert", "def", "abc"]
After Filtering, Final Array :
let filteredArray1 = [2,2,2]
let filteredArray2 = ["abc","abc","abc"]
I got the idea to get the count of elements from here:
Like getting the count of "abc" :
array2.filter{$0 == "abc"}.count
But is there any way to get the filtered array ?