Write a method called maxCount that returns the number of occurrences of the most frequently occurring value

Question:

Write a method called maxCount that returns the number of occurrences of the most frequently occurring value in a sorted list of integers. Because the list will be sorted, all duplicates will be grouped together, which will make it easier to count duplicates. For example, if a variable called list stores [1, 3, 4, 7, 7, 7, 7, 9, 9, 11, 13, 14, 14, 14, 16, 16, 18, 19, 19, 19], the call of list.maxCount() should return 4 because the most frequently occurring value (7) occurs four times. It is possible that there will be a tie for the most frequently occurring value, but that doesn’t affect the outcome because you are just returning the count, not the value. If there are no duplicates in the list, then every value will occur exactly once and the max count is 1. If the list is empty, the method should return 0.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: