Zepruv › Coding problems

Max Points on a Line

Hard · Array, Hash Table, Math, Geometry

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.

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

Starter code (python)

class Solution(object):
    def maxPoints(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        

Related problems

Previous: Sort List · Next: Maximum Product Subarray · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.