Given an array of integers, compute the difference between the maximum and minimum elements present in the sequence. The range is defined as the absolute difference between the largest value and the smallest value found within the array.
Explanation: The maximum element is 12 and the minimum element is 2. The range is 12 - 2 = 10.
Explanation: Both the maximum and minimum elements are 5. The range is 5 - 5 = 0.
Iterating arrays and tracking min/max
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak