Given a non-empty array of integers nums, return [min, max] computed in a single pass.
Minimum and Maximum (Set 1) — the data. This set runs 4 cases: nums holds arrays of 6–9 items, with values from -198 to 227. The hidden cases are the largest of the set.
Example 1
minAndMax()
Input
nums =[-155,75,-183,206,-7,-197]
Output
[-197,206]
Why
`minAndMax` returns `[-197, 206]`forthisinput.
Example 2
minAndMax()
Input
nums =[89,-184,-15,141,-147,35,152]
Output
[-184,152]
Why
`minAndMax` returns `[-184, 152]`forthisinput.
Constraints
1<=nums.length<=10^5-10^9<= nums[i]<=10^9
Every caseinthisset must pass: the first two are visible on Run, the last two unlock on Submit.
Topics
Arrays
Implement minAndMax in the editor and return the answer — printing it is never graded.