total =["a","a","a","b","b","b","b","b","b","b","b","c","c","c","d","d","d","d","d","d","d","d","b","b","e","e","e","e","e","f"]
smart_total = total.group_by{|i| i}.map{|i,j| [i,j.length]}
smart_total = [["a", 3], ["b", 10], ["c", 3], ["d", 8], ["e", 5], ["f", 1]]
我有样本数组
sample1 = ["a","f","b"]
根据最大频繁项,最终输出应该是一个元素,这里是b
sample2 = ["a","c"]
这里的输出可以是a
或者c
我正在寻找类似的东西
result1 = sample1.magik_function
=>"b"