Description
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.
Examples
Input:
points = [[1,1],[2,2],[3,3]]Output:
3Explanation:
All 3 points lie on the line y = x.
Input:
points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]Output:
4Explanation:
4 points lie on the same line.
Input:
points = [[0,0],[1,0],[2,0],[0,1],[0,2]]Output:
3Explanation:
There are two lines: a horizontal line through points [0,0], [1,0], [2,0] containing 3 points, and a vertical line through points [0,0], [0,1], [0,2] containing 3 points. Both lines share the point [0,0]. The maximum number of points on any single line is 3.
Constraints
- •
1 ≤ points.length ≤ 300 - •
-10⁴ ≤ xi, yi ≤ 10⁴