HotSpot
Rookie SRM 19 · 2023-03-17 · by erinn
Problem Statement
You are given a set of signal points along a number line, in
We call the point along the number line with the lowest total distance score the hotspot. Given a set of signal points, return the location of the hotspot.
Constraints
- points will contain between 1 and 50 elements.
- Each element of points will be between 0 and 100, inclusive.
{ 1, 5 }
Returns: 3.0
When there's two points, the best bet is to go right in the middle of the two.
{ 5 }
Returns: 5.0
{ 1, 10, 10 }
Returns: 7.0
{ 4, 7 }
Returns: 5.5
Note that the HotSpot point isn't necessarily an integer.
{ 99, 14, 62, 3 }
Returns: 44.5
The points aren't necessarily given in order.
Submissions are judged against all 7 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class HotSpot with a public method double bestPoint(vector<int> points) · 7 test cases · 2 s / 256 MB per case