Task about algorithms

  • 8
  • Locked
Every classical algorithm has been programmed for a long time. Still, tasks about algorithms are very valuable. At the very least, they make the programmer think. There's nothing complicated about the algorithm to find the maximum. So let's not dilly-dally: write a program that takes a positive integer n, takes n numbers, and then finds the maximum of them.
You can't complete this task, because you're not signed in.
Comments (50)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 9 , Milan, Italy
1 November 2022, 18:32
maybe i don't understand, but this task is over my knowledge....
Level 0
26 July 2021, 10:55
how can I help to you dear I try to this NaTasia Madison
NaTasia Madison
Level 8 , Atlanta, United States
26 July 2021, 02:40
When looking at the solution, I am still confused. I don't really understand the arrays. Can someone explain step by step, please.
Hisham Thabet
Level 7 , Lahj, Yemen
6 August 2021, 07:29
This task is not clear enough, but you can try until solve it . Read the commonts below ,they are very useful.
Jeffrey Janaczek
Level 9 , Tampa, United States
20 June 2021, 09:10
After working on it for 15 minutes I was still confused about what they wanted. I felt that my only option was to copy the solution and run it multiple times. The description at the bottom will give you a better idea of what they want. When I copied and pasted the solution I kept myself from looking at the solution itself and focused only on the output. Getting the solution took me a few hours. My solution was completely different from theirs. I didn't use any built in functions like Integer.MIN_VALUE/Integer.Max_Value and no for loops. I used one if statement, ternary operators, if/else statements and a while loop. I felt that the hardest part was getting it to work with negative numbers such as: 3 ( this means you will enter 3 numbers) -7 (1st number) -2 (2nd number) -5 (3rd) number) -2 (outputs the maximum/highest number)
Level 15 , Old Town, United States
9 April 2021, 04:06
12 tries!!! Initially, didn't understand the instruction correctly! the first N stands for a number, which represents how many times it will read the number from the keyboard.
Level 11 , Banja Luka, Bosnia and Herzegovina
24 February 2021, 10:54
The key question here is until when the program should ask for a user input? As it is stated it would run forever. There must be some condition when the loop would break, either to define the number of inputs or to define some keyword when the loop exits. The proposed solution does not properly calculate the output. Enter this: 5 6 7 71 9 19 235435 You'll get an output of 71.
Guadalupe Gagnon
Level 37 , Tampa, United States
26 July 2021, 15:37
The correct answer in that sequence is 71....
Level 22 , Iasi, Romania
5 December 2020, 07:53
i took a look in the solution they say is correct and i made 4 other versions, all worked perfectly but still it said is not correct. so you haft to make the code exactly as they did. who made this task is an "amazing" boss somewhere....
kar-fai chow
Level 8 , Hong Kong, Hong Kong
18 November 2020, 22:43
will the input set have enough numbers for the initial N? e.g. if the first number is 999, will there be another 999 numbers to satisfy the number set? or do i have to handle that as well? My codes are running fine: handing the first N being negative, reading N more numbers, returning Max, handling all negative N numbers etc But apparently it is still not returning the maximum number CodeGym needs to be more specific on why I am failing This is getting to be a waste of my time
Level 9 , Vilnius, Lithuania
29 September 2020, 20:16
29 tries.... although the code worked like a charm, couldn't pass the 5th requirement. Using MIN_VALUE fixed that, idk why... In case You take this approach don't forget to "import static java.lang.Integer.MIN_VALUE;"
Bernd Lauert
Level 10 , Bremen, Germany
14 July 2021, 09:12
Thanks, i did that and it worked perfectly.
Karas Java Developer
1 September 2020, 17:52
A little too confusing. Hint: use a for loop. make sure you maximum to Integer.MIN_VALUE and two if statements.