Murderer00's blog

By Murderer00, history, 4 years ago, In English

-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){ } } }

}

  • Vote: I like it
  • -1
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

.