<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>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane1.jpg" style="width: 300px; height: 294px;" />
<pre>
<strong>Input:</strong> points = [[1,1],[2,2],[3,3]]
<strong>Output:</strong> 3
</pre>

<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/25/plane2.jpg" style="width: 300px; height: 294px;" />
<pre>
<strong>Input:</strong> points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]
<strong>Output:</strong> 4
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= points.length &lt;= 300</code></li>
	<li><code>points[i].length == 2</code></li>
	<li><code>-10<sup>4</sup> &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 10<sup>4</sup></code></li>
	<li>All the <code>points</code> are <strong>unique</strong>.</li>
</ul>

class Solution {
public:
    int maxPoints(vector<vector<int>>& points) {
        /*if(points.size() == 2){
            if(points[0][0] == points[1][0] || points[0][0] == points[1][1]  ){
                return 2;
            }
             if(points[0][1] == points[1][0] || points[0][1] == points[1][1]  ){
                return 2;
            }
        }*/
        int q = 1;
        int y = 1;

        for(int i = 1 ; i<points.size() ; i++){
          if(points[i][0] == points[0][0] ||  points[i][1] == points[0][0] ){
            q++;
          }
          if(points[i][0] == points[0][1] ||  points[i][1] == points[0][1]){
            y++;
          }
        }
        if(y == points.size()  || q == points.size()){
            return points.size();
        }
        if(points.size() == 1){
            return 1;
        }
        map< int, map<float, set<vector<int>>>>m;
        float d = 0.00;
        for(int i = 0 ; i<points.size()-1 ; i++ ){
            for(int j = i+1 ; j<points.size() ; j++){
                //cout<<points[j][1]<<points[i][1]<<points[j][0]<<points[i][0]<<endl;
                if((points[j][0] - points[i][0]) == 0){
                    //cout<<points[j][1]<<points[i][1]<<points[j][0]<<points[i][0]<<i<<endl;
                    m[i][INT_MAX].insert({points[j][0] , points[j][1]});
                    m[i][INT_MAX].insert({points[i][0] , points[i][1]});
                  //continue;  
                }else{
                //float r ;
                //cout<<points[j][1]<<points[i][1]<<points[j][0]<<points[i][0]<<endl;
                float g = (points[j][1] - points[i][1]);
            
               float h =  (points[j][0] - points[i][0]);

               //cout<<g<<"  g  "<<h<<endl;
               
            d  = g/h;
            //cout<<d<<" r "<<endl;
               
            //cout<<r<<" r "<<endl;
            //d = r;
            m[i][d].insert({points[j][0] , points[j][1]});
            m[i][d].insert({points[i][0] , points[i][1]});
            }
            }
        }
         int c = INT_MIN;
        for(auto i : m){
            for(auto j : i.second){
            //cout<<j.first<<"  "<<j.second.size()<<endl;
           int w = j.second.size();
     if(c<w){
        c = j.second.size();
     }
            }
        }
      /* if(y > c  ){
        return y;
       }

       if(q>c){
        return q;
       }*/
        return c;
    }
};
92973