Write a function normalize(arr) that normalizes an array to the range [0, 1] using min-max scaling.
Formula: normalized_value = (value - min) / (max - min)
Example:
Input: arr = [10, 20, 30, 40, 50]
Output: [0.0, 0.25, 0.5, 0.75, 1.0]
Constraints:
Test Cases
Test Case 1
Input:
[10, 20, 30, 40, 50]Expected:
[0.0, 0.25, 0.5, 0.75, 1.0]Test Case 2
Input:
[0, 100]Expected:
[0.0, 1.0]Test Case 3
Input:
[1, 2, 3]Expected:
[0.0, 0.5, 1.0]+ 2 hidden test cases