Skip to content

Practice Max Points on a Line

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#149
LeetCode Problem

Max Points on a Line

Problem Statement

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.

Source: Max Points on a Line on LeetCode. Use the original task for its coding environment and submissions.

Examples

# 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

Constraints

1 <= points.length <= 300
points[i].length == 2
-10^4 <= xi, yi <= 10^4
All the points are unique.

Related LeetCode Problems

Practice more problems similar to Max Points on a Line.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.