id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2020_10_01_HL_mostFrequent
prev  |  next  |  chance

Write a method that returns the most frequently occuring element in an array of positive integers. The array will ONLY contain integers in the range 1 to 100. This is more difficult than it seems! As a precondition, you may assume that there IS a single, most frequently occuring element (no ties).


test2020_10_01_HL_mostFrequent([7, 4, 2, 19, 44, 55, 78, 19, 23, 44, 19, 7, 4, 19, 5, 17, 19, 22, 19, 55]) → 19
test2020_10_01_HL_mostFrequent([42, 85, 99, 100, 77, 100, 27, 100, 13, 14, 15, 100, 94, 93, 15, 15, 100, 27, 29, 39, 49, 42]) → 100
test2020_10_01_HL_mostFrequent([1, 1, 1, 1, 1, 1]) → 1

...Save, Compile, Run (ctrl-enter)

public int test2020_10_01_HL_mostFrequent(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy