Official algorithmic problem description and constraints.
Consider a set of points on a line. The distance between two points π and π is |πβπ|.
The point π from the set is the closest to the point π from the set, if there is no other point π in the set such that the distance from π to π is strictly less than the distance from π to π. In other words, all other points from the set have distance to π greater or equal to |πβπ|.
For example, consider a set of points {1,3,5,8}:
You are given a set of points. You have to add an integer point into this set in such a way that it is different from every existing point in the set, and it becomes the closest point to every point in the set. Is it possible?
Detailed video explanations, mathematical intuition, and clean C++ implementation code.