149. Max Points on a Line
Difficulty: Hard
Given _n_ points on a 2D plane, find the maximum number of points that lie on the same straight line.
给出一堆二维的点,求出在同一条线上的点的最多个数。
Solution
pi pj就可以构成一个线,因此,所有的线一共有n*(n-1)种,判断的时候,每次要全部遍历,因此时间复杂度为O(n^3)
1 | /** |
这样的做法会超时
1 |
|