This is the best approach fellas

amazon
Tags: #<Tag:0x00007f24267cd700>

#1

best apprach to solve.

Blockquote
int Solution::maxPoints(vector &A, vector &B) {
// Do not write main() function.

// Do not read input, instead use the arguments to the function.
// Do not print the output, instead return values as specified
// Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details

int n=A.size();
int xdif,ydif,g;
int maxslope=0;
map<pair<int,int >,int>m;
if(n<2){
    return n;
}
for (int i=0;i<n;i++){
    int overlapping=0,vertical=0,currslope=0;
    for(int j=i+1;j<n;j++){
        if(A[i]==A[j] && B[i]==B[j]){
            overlapping++;
        }
        else if(A[i]==A[j] ){//&& B[i]!=B[j]){
            vertical++;
  
  }
        else{
            ydif=B[j]-B[i];
            xdif=A[j]-A[i];

g= __gcd(ydif,xdif);
xdif/=g;
ydif/=g;
m[make_pair(ydif,xdif)]++;
currslope=max(currslope,m[make_pair(ydif,xdif)]);

        }
        currslope=max(currslope,vertical);
        
    }
    maxslope=max(maxslope,currslope + overlapping+1);
    m.clear();
}
return maxslope;

}