Find minimum and maximum element in an array
Basic Accuracy: 59.4% Submissions: 26534 Points: 1

Given an array A of size N of integers. Your task is to find the minimum and maximum elements in the array.


Example 1:

N = 6
A[] = {3, 2, 1, 56, 10000, 167}
min = 1, max =  10000


Example 2:

N = 5
A[]  = {1, 345, 234, 21, 56789}
min = 1, max = 56789


Your Task:  
You don't need to read input or print anything. Your task is to complete the function getMinMax() which takes the array A[] and its size N as inputs and returns the minimum and maximum element of the array.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)


1 <= N <= 105
1 <= Ai <=1012

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Find minimum and maximum element in an array

Output Window