Maximum and Minimum of an Array
You are given an integer array nums of size N. Your task is to find the maximum and minimum elements in the array.
- Maximum: The largest element in the array.
- Minimum: The smallest element in the array.
Return the maximum and minimum elements of the given array.
Example 1:
Input:
nums = [1, 2, 3, 4, 5]
Output:
5 1
Explanation:
The maximum element from given array is 5.
The minimum element from given array is 1.
Example 2:
Input:
nums = [1, 0, 2, -10]
Output:
2 -10
Explanation:
The maximum element from given array is 2.
The minimum element from given array is -10.
Now Your Turn!
Pick the correct output for the given inputInput:
nums = [4, 1, 0, 6, -12]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= N <= 100
- -105 <= nums[i] <= 105