DSAMaster Logo
DSAMaster
BackeasyArrays

Magnitude Range Extent

Problem Description

Given an array of integers representing signal magnitudes, calculate the absolute difference between the largest and smallest values found within the array.

Example 1
Input
[12, 5, 8, 20, 3]
Output
17

Explanation: The maximum value is 20 and the minimum value is 3. The absolute difference is 20 - 3 = 17.

Example 2
Input
[7, 7, 7, 7]
Output
0

Explanation: The maximum value is 7 and the minimum value is 7. The absolute difference is 7 - 7 = 0.

Example 3
Input
[-10, 0, 10]
Output
20

Explanation: The maximum value is 10 and the minimum value is -10. The absolute difference is 10 - (-10) = 20.

Constraints

  • 1 <= array.length <= 1000
  • -10^4 <= array[i] <= 10^4
00:00
Loading...

Sign in to Solve

Access the full code editor, ThinkBuddy AI hints, and track your progress.

Sign in Free
Test Cases & Output
Enter test input here...
Click "Run Code" to execute