Skip to content
Onsite

Smallest and Largest of All

EasyP3Coding

Return [smallest, largest] for the elements of nums.

Example 1

Input
nums = [3,1,4,1,5]
Output
[1,5]

Example 2

Input
nums = [7]
Output
[7,7]

Example 3

Input
nums = [-2,-5,-1]
Output
[-5,-1]

Constraints

  • 1 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.