Given a non-empty array of integers nums, return the maximum and minimum values as a two-element array [max, min].
For example, given [3, 1, 4, 1, 5], the maximum is 5 and the minimum is 1, so return [5, 1].
nums = [3, 1, 4, 1, 5][5, 1]nums = [42][42, 42]nums = [-10, -20, -3][-3, -20]1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9Run your code to see results
Use Cmd+Enter to run