brewersfan1976

array_mode.rb

Jun 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.15 KB | None | 0 0
  1. def arrayMode(sequence)
  2.     h = Hash.new(0)
  3.     sequence.each {|i| h[i] += 1}
  4.     output = h.max {|a,b| a[1] <=> b[1]}
  5.     return output[0]
  6. end
Advertisement
Add Comment
Please, Sign In to add comment