Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Блог пользователя Murderer00

Автор Murderer00, история, 4 года назад, По-английски

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

}

  • Проголосовать: нравится
  • -1
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

.