DataInput/output Stream Problem Java. Need help guys. Can anyone solve this.

Revision en2, by Murderer00, 2020-08-01 09:06:56

-Problem--

Write a program that takes a single linked list of integers (from 0 to 10) of positive size N and gives As output the number that occurs the maximum number of times, from the inputted list. The input will be given in one line in the following format. N a1 a2 a3 a4 a5 … an ‘N’ is the size of the list and a1,a2,a3,… an, are the integers present on the list indicating that a1 has a link to a2,a2 has a link to a3 and so on. If more than one number appear the maximum number of times, you should Give as output the greatest one.

Example

Case 1: For the input provided as follows: 7 1 5 1 4 9 0 4 Output program will be: 4 Description: Both 1 and 4 appear the maximum number of times(two times), but 4 is The greatest one out of the two, so the output is 4.

Case 2: For the input provide as follows: 7 1 10 0 5 2 3 9 Output of the program will be: 10 Description: All number appear only once, so you should choose the greatest one that is 10.

--------Provided Code to Start------------------------------------------------------------------------------------------------

Import java.io.*; Public class Main { Public static void main(String [] args) throws java.lang.Exception{ String line; DataInputStream in = new DataInputStream(System.in); While((line=in.readLine())!=null){ } } }

}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Murderer00 2020-08-01 09:06:56 2 Tiny change: 'readLine()0!=null){\n' -> 'readLine())!=null){\n'
en1 English Murderer00 2020-08-01 05:25:45 1556 Initial revision (published)