Created
October 31, 2014 20:44
-
-
Save bionicpill/47068f8ac5aca7e0c0ed to your computer and use it in GitHub Desktop.
Find most popular item in the array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def popular(arr) | |
b = a.uniq | |
c = 0 | |
b.map {|x| c = x if a.count(x) > c} | |
c | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment