Max Points on a Line
Given an array points where points[i] = [x, y] is a point on the plane, return the maximum number of points that lie on the same straight line.
No two points in the input are the same. A single point, or a pair of points, always counts as lying on a line.
Example cases
- diagonalin points =112233out 3All three points sit on the line y = x.
- line plus stragglersin points =113253412314out 4(3,2), (4,1), (2,3), and (1,4) all satisfy x + y = 5; the other two points aren't on that line.
- single pointin points =00out 1One point trivially counts as lying on a line.
- two pointsin points =0055out 2Any two distinct points always lie on some line together.
Constraints
- 1 <= points.length <= 300
- points[i].length == 2
- -10^4 <= points[i][0], points[i][1] <= 10^4
- All points in the input are unique.
points =
[[1,1],[2,2],[3,3]]