Welcome back to week eight of the weekly programming contests! If you are new to the contest or need a refresher don’t forget to read up on the rules and information Posted Here
This weeks challenge is to write a method (you can call it anything you want) that takes in a non-empty integer array and returns an the number of times the most frequently occurring element in the array appears (i.e. the number of times the mode appears in the array).
Examples:
mode({-4, 8, 3, -2, -2, 11, -3, 4, 10, 11}) -> 2
mode({-2, -4, 8, 15, 9, 5, 5, -5, 17, 8}) -> 2
mode({-1, 11, 15, 12, 7, -1, 20, 4, 12, -1}) -> 3
mode({2, 13, 1, 11, 12, 11, 5, 17, 18, 2}) -> 2
mode({14, 7, 7, 2, 5, 9, 5, 5, 1, 12}) -> 3
mode({6, 8, 12, 10, 19, -2, 12, 19, 11, 19}) -> 3
mode({-2, -4, -2, 19, 3, 4, 17, -5, 9, 13}) -> 2
mode({7, -1, 1, 15, 15, 8, -2, 4, -5, 8}) -> 2
mode({0, 6, 14, 16, 19, 15, 3, 14, 18, 12}) -> 2
mode({17, 19, 11, 18, 9, 10, 0, 1, 4, -2}) -> 1
Imports are allowed for this challenge!
Challenge Closes: Sunday 12/27/15
Good luck!