Class Solution

java.lang.Object
g0101_0200.s0149_max_points_on_a_line.Solution

public class Solution extends Object
149 - Max Points on a Line.<p>Hard</p> <p>Given an array of <code>points</code> where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents a point on the <strong>X-Y</strong> plane, return <em>the maximum number of points that lie on the same straight line</em>.</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg" alt="" /></p> <p><strong>Input:</strong> points = [[1,1],[2,2],[3,3]]</p> <p><strong>Output:</strong> 3</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg" alt="" /></p> <p><strong>Input:</strong> points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]</p> <p><strong>Output:</strong> 4</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= points.length <= 300</code></li> <li><code>points[i].length == 2</code></li> <li><code>-10<sup>4</sup> <= x<sub>i</sub>, y<sub>i</sub> <= 10<sup>4</sup></code></li> <li>All the <code>points</code> are <strong>unique</strong>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxPoints

      public int maxPoints(int[][] points)