Min-Max Feature Scaling
Before training, a pipeline rescales a numeric feature so that its smallest value becomes 0 and its largest becomes 1: each value v becomes (v - min) / (max - min).
Round every result to 4 decimal places with Math.round(x * 10000) / 10000. If all values are equal (including a single value), return all zeros. An empty input returns [].
Example 1
Input: values = [10,20,30] Output: [0,0.5,1] Explanation: min 10, max 30, so 20 maps to 0.5.
Example 2
Input: values = [3,1,2,4] Output: [0.6667,0,0.3333,1]
Constraints
- 0 <= values.length <= 10^5
- -10^9 <= values[i] <= 10^9
Hint 1
Find min and max in one pass, then map.
Hint 2
Guard against dividing by zero when max equals min.
Good practice for: Data Scientist, Machine Learning Engineer, AI Engineer (LLM & Generative AI), MLOps Engineer, Data Engineer
Run checks your code on 3 sample tests. Submit runs all 8 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.