Given an array of points where points[i] = [x_i, y_i] represents coordinates on a 2D plane, find the maximum number of points that lie on the same straight line.
This is a classic computational geometry problem that tests your understanding of slope calculations, hash tables, and mathematical precision. You'll need to consider edge cases like vertical lines, identical points, and floating-point precision issues.
Key Challenge: Two points always form a line, but finding the maximum number of collinear points requires checking all possible line combinations efficiently.
Input & Output
Visualization
Time & Space Complexity
For each of n points, calculate slopes to all other n points. Hash operations are O(1) average case.
Hash table to store slope frequencies for each anchor point, maximum n-1 entries per iteration
Constraints
- 1 โค points.length โค 300
- points[i].length == 2
- -104 โค xi, yi โค 104
- All points are unique except for duplicates explicitly mentioned