#149

Max Points on a Line

international master · 1975 · lc hard +32 · verified · 30.3% accepted · 4,506 likes · top 7%

play →

Description

You are given an array points where each points[i] = [xi, yi] is a point on the X-Y plane. Return the maximum number of points that all lie on the same straight line.

Example 1:

Input: points = [[1,1],[2,2],[3,3]]
Output: 3

Example 2:

Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
Output: 4

Code

1
2
3