Most Survey Points on One Line
A land survey recorded distinct integer points points[i] = [x, y]. Return the largest number of points that lie on a single straight line.
Avoid floating-point slopes: they can make different lines look equal.
Example 1
Input: points = [[1,1],[2,2],[3,3]] Output: 3
Example 2
Input: points = [[0,0],[0,5],[0,-3],[2,2]] Output: 3 Explanation: The vertical line x = 0 holds three points.
Constraints
- 0 <= points.length <= 300
- -10^4 <= x, y <= 10^5
- All points are distinct.
Hint 1
Fix an anchor point and group the other points by the direction towards them.
Hint 2
Represent a direction as a reduced fraction (dx / g, dy / g) with a normalised sign.
Good practice for: Embedded Systems Engineer, Game Developer, Backend Developer, Blockchain Developer, Data Scientist, Machine Learning Engineer
Run checks your code on 2 sample tests. Submit runs all 9 tests, including hidden ones, and earns points. Use console.log to debug. Python's first run can take a few seconds while it starts.