As reported: D. E. Shaw Quality and Test Engineer interview (April 2025): one of four DSA problems given as LeetCode links — Max Points on a Line.
This is LeetCode 149 — Max Points on a Line. Our write-up: /max-points-on-a-line.
Given an array points where points[i] = [xi, yi], return the maximum number of points that lie on the same straight line.
Example 1
points = [[1,1],[2,2],[3,3]]
Output: 3
Example 2
points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
Output: 4
Constraints: 1 ≤ points.length ≤ 300; -10^4 ≤ xi, yi ≤ 10^4; all points are distinct.
Code runner format: one JSON value per line: points. Implement maxPoints(points).