Max Points on a Line
Hard
LC #149
hash maptuple keysmathgeometryNot attempted yet
You're given a list of distinct points on a plane, each
[x, y] with integer coordinates. Return the largest
number of points that lie on one straight line.
Example 1
Input: points = [[1, 1], [2, 2], [3, 3]]
Output: 3
Example 2
Input: points = [[1, 2], [2, 4], [0, 5],
[3, 6], [4, 1], [5, 10]]
Output: 4
[1,2], [2,4], [3,6], [5,10] are on y = 2x.
Example 3
Input: points = [[0, 0]]
Output: 1
Constraints
- 1 ≤ len(points) ≤ 300
- -10^9 ≤ x, y ≤ 10^9
- All points are distinct