Given an array of numbers, find both the minimum and maximum using fewer than 2*(n-2) comparisons. Use a divide-and-conquer approach. Input: first line n, second line n space-separated integers. Output: minimum and maximum separated by space.
Example 1:
Example 2:
Constraints:
1 <= n <= 10^5 -10^9 <= arr[i] <= 10^9
Tags: