Make a frequency table (histogram)
+0
−0
Challenge
Given an array in any suitable format, create a frequency table for it. i.e: Pair each unique element with the number of times it appears in the array.
You can return the frequency table as a list of pairs, hashmap/dictionary, output the pairs directly, etc.
Tests
{ 1 1 2 3 5 6 6 } -> { { 1 2 } { 2 1 } { 3 1 } { 5 1 } { 6 2 } }
{ } -> { }
{ 1 6 7 1 2 6 6 1 53 4 10 } -> { { 1 3 } { 2 1 } { 4 1 } { 53 1 } { 6 3 } { 7 1 } { 10 1 } }
0 comment threads