Computer Science, asked by nishant6092, 11 days ago

write a program to enter 5 number in an array and print the number with the largest frequenc​

Answers

Answered by shoaib050670
0

Input: arr = [3, 2, 5, 2, 4, 5]

Output: 2

Explanation:

In this given array frequency of 2 is 2, whereas the frequency of the remaining numbers doesnt match with itself. So the answer is 2.

Input: arr = [3, 3, 3, 4, 4, 4, 4]

Output: 4

Explanation:

In this given array frequency of 3 is 3 and 4 is 4 but largest number is 4. So the answer is 4.

Input: arr = [1, 1, 1, 2, 3, 3]

Output: -1

Explanation:

There is no such number in the given array whose frequency is equal to itself. Thus the output is -1.

Similar questions