max-points-on-a-line

时间限制:1秒 空间限制:32768K

题目描述

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

我的代码

/**
 * Definition for a point.
 * struct Point {
 *     int x;
 *     int y;
 *     Point() : x(0), y(0) {}
 *     Point(int a, int b) : x(a), y(b) {}
 * };
 */
class Solution {
public:
    int maxPoints(vector &points) {
        int num=points.size();
        if(num<2)
            return num;
        int count=0;
        for(int i=0;i,int> m;
            int cnt=0,numSame=0;
            for(int j=i+1;j

运行时间:8ms
占用内存:360k

你可能感兴趣的:(max-points-on-a-line)