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?
Minimum and Maximum
- 7
Locked
Comments (15)
- Popular
- New
- Old
You must be signed in to leave a comment
John Doe
28 December 2019, 11:27
I don't understand why the verification doesn't pass
0
R3fiX
5 October 2019, 10:18
Can somebody explain what is the meaning of capital letters X and Y in Pair class?
0
Corina Bodea
10 April 2020, 16:12
They are called generics.
Here's a link about that: https://www.geeksforgeeks.org/generics-in-java/
+2
Nirali Rawal
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.
+1
R3fiX
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
0
Switch/Cypher
22 September 2020, 07:33
I copied the values into a new array, then just did Arrays.sort. That's simpler?
0
Vitalina
31 October 2020, 22:36
It is simpler but then you'll modify array. And the task says you cannot do it.
0
Switch/Cypher
1 November 2020, 11:09
I'm only modifying the new array though.
0
Vitalina
1 November 2020, 15:38
I've tried to do it as well but Codegym didn't accept it.
0
Andrei
23 November 2020, 08:56
Yes, you can use two IF's in one for loop , for the min and max!
0
Khongpak Phupkdee
24 July 2021, 14:40
Thank you
0
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 )
0
Learner
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".
0
Roman
1 October 2018, 05:44
Some students change this method so we warn.
0
Learner
1 October 2018, 06:06
It is not verifying because of that.
0