Spring Boot Interview Question: Batch Normalization API
Normalization, Performance, CPU bound, Code samples and more.
Scenario
You are building a data analytics service that receives numeric metrics from various clients and normalizes them into a fixed range before further processing.
This service will expose a REST API that accepts a batch of numeric values and returns the normalized results.
Problem Statement
Create a Spring Boot REST API with a POST endpoint
/normalize.The endpoint should accept a JSON payload:
{
"values": [50, 75, 120, -10],
"targetMin": 0,
"targetMax": 1
}The API should return the normalized values as a JSON array:
[0.5, 0.875, 1.0, 0.0]The API should handle edge cases:
Empty arrays
All identical values (map to middle of target range)
Inverted target ranges (e.g.,
[1,0])
π’ Get actionable Java/Spring Boot insights every week β from practical code tips to real-world use-case based interview questions.
Join 5000+ subscribers and level up your Spring & backend skills with hand-crafted content β no fluff.
First 100 paid subscribers will get the annual membership at $50/year ( 60 already converted to paid, 40 remaining )
Not convinced? Check out the details of the past work
Solution
From the problem statement , it feels like we need to focus on 3 things:
Data modeling β defining the input and output.
Normalization logic β how we actually compute normalized values.
Exposing the API β building a Spring Boot endpoint for clients.
Data modeling
For the request, we should define a DTO with:
An array of doubles,
valuestargetMinandtargetMax
This keeps the API flexible, since clients can normalize into any range they want.



