Given an array
arr[]
of size
n
, write a program to find the
maximum and minimum
element present in the array.
Problem Note
- Your algorithm should make the minimum number of comparisons.
Example 1
Input: arr[] = [4, 2, 0, 8, 20, 9, 2]
Output: Maximum = 20, Minimum = 0
Example 2
Input: arr[] = [-8, -3, -10, -32, -1]
Output: Maximum = -1, Minimum = -32