Maximum and Minimum Of Array Elements
Submissions: 10274   Accuracy:

49.96%

  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

Given an array A[ ], find maximum and minimum elements from the array.

Input:
The first line of input contains an integer T, denoting the number of testcases. The description of T testcases follows. The first line of each testcase contains a single integer N denoting the size of array. The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.

Output:
For each testcase in a new line, print the maximum and minimum element in a single line with space in between.

Constraints:
1 ≤ T ≤ 30

1 ≤ N ≤ 100
0 ≤A[i]<100

Example:
Input:

2
4
5 4 2 1
1
8

Output:
5 1
8 8

Explanation:
Testcase 1:

Maximum element is: 5 
Minimum element is: 1

** For More Input/Output Examples Use 'Expected Output' option **

Author: shef5


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.