Array Maximum and Minimum
Array Maximum and Minimum
You are given N integers. Print the largest and the smallest of them on one line, separated by a single space — maximum first.
The first input line gives N, and the second line gives the N numbers separated by spaces.
If N is 1, that single number is both the maximum and the minimum, so it is printed twice.
Start both your maximum and your minimum at the first element of the array — not at 0, which breaks as soon as every number is negative.
Line 1: the integer N. Line 2: N space-separated integers.
Two integers on one line: the maximum, then the minimum.
1 <= N <= 10^5, and each element is between -10^9 and 10^9
5 3 1 4 1 5
5 1
The largest value is 5 and the smallest is 1.
Submit runs your code against 5 test cases — the 1 shown above plus 4 hidden ones covering the awkward cases. Run sample just tries the first example, which is usually what you want while you are still working it out.