Range of Data

EasyStatisticsArray

Description

Given an array of numbers nums, return the range, defined as the maximum value minus the minimum value.

Examples

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

Subtracting the smallest value from the largest spans 4.

Input:nums = [10,10]
Output:0
Explanation:

Subtracting the smallest value from the largest spans 0.

Input:nums = [-5,0,7]
Output:12
Explanation:

Subtracting the smallest value from the largest spans 12.

Constraints

  • 1 ≤ nums.length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.