Question: code in java Read integer values into an array. Print the value in the array that appears the most. If more than one value appears
code in java
Read integer values into an array. Print the value in the array that appears the most. If more than one value appears the most, print the value that appears closest to the start of the input.
Input Format
The first line contains the number of integers in the array The second line contains the values in the array
Constraints
1 <= size of array <= 10000 the elements of the array can be any legal java integer value.
Output Format
The value of the element that appears the most number of times.
Sample Input 0
10 6 5 2 6 4 3 2 9 2 5
Sample Output 0
2
Explanation 0
The value 2 appears 3 times in the 10 element list
-----------------------------------------------------------------------------
import java.io.*; import java.util.*;
public class Solution {
public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
