SCALER (INTERVIEWBIT) On-Campus OA (2023) | Max Points on a Line (Count Collinear Points)

Question · Posted Jun 2026

Problem Statement Given an array of points where points[i] = [xi, yi], determine the maximum number of points that lie on the same straight line. A set of points is considered collinear if all points lie on a single straight line. Return the maximum number of collinear points. Example Input: points = [[1,1],[2,2],[3,3]] Output: 3 Explanation: All three points satisfy the equation: y = x Hence, all points lie on the same line. Test Cases Test Case 1 Input: points ...

The full answer & interview discussion are available to premium members.

Log in Create a free account