Compute point-to-segment minimum distance
Company: LinkedIn
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of computational geometry and numerical robustness, testing the ability to compute Euclidean distances between a point and a line segment using analytic geometry concepts.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ((1,1), (0,0), (2,0))
Expected Output: 1.0
Explanation: Projection falls on segment.
Input: ((3,0), (0,0), (2,0))
Expected Output: 1.0
Explanation: Closest to endpoint.
Input: ((1,1), (0,0), (0,0))
Expected Output: 1.414214
Explanation: Degenerate segment.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.