Question: You are given an implementation of a function: class Solution { public int solution ( int M , int [ ] A ) ; that,
You are given an implementation of a function:
class Solution public int solutionint M int A;
that, given an integer M and an array A consisting of N nonnegative integers,
which are not greater than M returns the value or one of the values that occurs most often in this array.
For example, given M and array A such that:
A
A
A
A
A
A
A
the function may return or
The attached code is still incorrect for some inputs.
Despite the errors the code may produce a correct answer for the example test cases.
The goal of the exercise is to find and fix the bugs in the implementation. You can modify at most four lines.
Assume that:
N is an integer within the range ;
M is an integer within the range ;
each element of array A is an integer within the range M
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment. Write the answer Java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
