```
/**
* 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<Point> &points) {
int m, i, j, k, n, m_max=0;
n = points.size();
if (n<=2) return n;
for(i=0;i<n;i++){
m = 1;
for(j=i+1;j<n;j++){
if((points[i].x==points[j].x)&&(points[i].y==points[j].y)) {m++; continue;}
m++;
for (k=j+1;k<n;k++) if (check_collinear(points[i], points[j], points[k])) m++;
m_max = max(m_max, m);
m=1;
}
m_max = max(m_max, m);
}
return m_max;
}
bool check_collinear(Point p1, Point p2, Point p3){
return ((p1.x-p3.x)*(p1.y-p2.y)==(p1.x-p2.x)*(p1.y-p3.y));
}
};
```

General algorithm - for every pair of pair of points, count how many other points are on the same line.

(caution: if your initial pair has two identical points, you get an extra 'free' collinear point but must proceed until you find a different point to base your comparisons off).

I know O(n^3) when O(n^2) is achievable. But no TLE, and in any case would like to know what's going wrong

Thanks!