Question: Write a function named hasSingleMaximum that takes an array argument and returns 1 if the maximum value in its array argument occurs exactly once in

Write a function namedhasSingleMaximumthat takes an array argument and returns 1 if the maximum value in its array argument occurs exactly once in the array, otherwise it returns 0.
N.B: you are writing in Java the function signature is
int hasSingleMaximum(int[] a)
Examples
if a is return reason
{1,2,3,1,0}1 because the maximum value 3 occurs only once in the array
{18}1 because the maximum value 18 occurs exactly once in the array
{1,2,3,0,1,3}0 because the maximum value 3 occurs twice in the array
{13,1,13,2,13,0,13,1,13}0 because the maximum value 13 occurs more than once in the array
{}0 because there is no maximum value
{-6,-6,-6,-6,-6,-6,-6}0 because the maximum value -6 occurs more than once in the array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!