Minimum and Maximum

  • 7
  • Locked
During his pre-school entrance exam, Alex, an ordered isomorph from Planet Linear Chaos, was tasked with finding the minimum and maximum values in an array. As you may remember (or not), the only thing that people on this planet do is sort and compare. Alex was able to do it. Can you?
You can't complete this task, because you're not signed in.
Comments (15)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
John Doe
Level 18 , london, England
28 December 2019, 11:27
I don't understand why the verification doesn't pass
Level 12 , Tarnow, Poland
5 October 2019, 10:18
Can somebody explain what is the meaning of capital letters X and Y in Pair class?
Corina Bodea
Level 14 , Cluj Napoca, Romania
10 April 2020, 16:12
They are called generics. Here's a link about that:
Nirali Rawal
Level 15 , Hopewell, United States
2 October 2019, 18:41
Is there a better way of writing this code? I feel like the for loop that was used twice could be simplified. Just not exactly sure how.
Level 12 , Tarnow, Poland
5 October 2019, 10:20
You can establish max and min at once in one for loop, that's the only simplification I can come up with
Level 25 , Bexleyheath, United Kingdom
22 September 2020, 07:33
I copied the values into a new array, then just did Arrays.sort. That's simpler?
Level 20 , Poland
31 October 2020, 22:36
It is simpler but then you'll modify array. And the task says you cannot do it.
Level 25 , Bexleyheath, United Kingdom
1 November 2020, 11:09
I'm only modifying the new array though.
Level 20 , Poland
1 November 2020, 15:38
I've tried to do it as well but Codegym didn't accept it.
Level 41
23 November 2020, 08:56
Yes, you can use two IF's in one for loop , for the min and max!
Khongpak Phupkdee
Level 15 , Chiangrai, Thailand
24 July 2021, 14:40
Thank you
Hiyo Full Stack Developer
1 February, 12:10
Loop over array once, find min and max values at the same time. Assign them to the pair at the end. O(n) speed, O(1) memory ( 2 int variables used regardless of array size )
Level 16 , India
29 September 2018, 05:33
Something not right with this task. There is no change in main method and yet it fails stating "Don't change the main method".
Level 41
1 October 2018, 05:44
Some students change this method so we warn.
Level 16 , India
1 October 2018, 06:06
It is not verifying because of that.