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.
Input: points = [[1,1],[2,2],[3,3]]
Output: 3
Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
Output: 4
This approach considers all combinations of pairs to determine every possible line. For each line, we check how many points from the input lie on it.
Instead of evaluating every pair by brute force, leverage the properties of the slope of lines and use a HashMap to optimize the counting of points on a similar slope from a given point.