<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:
    pair<double,double>find_m_c(vector<int>a,vector<int>b)
    {
        if(a[0]==b[0])
        {
            return {a[0],INT_MAX};
        }
        double slope=(a[1]-b[1])/((a[0]-b[0])/1.0);
        double c=a[1]-slope*a[0];
        return {slope,c};
    }
    int maxPoints(vector<vector<int>>& points) {

        map<pair<double,double>,set<vector<int>>>temp;
        if(points.size()==1)
        {
            return 1;
        }
        for(int i=0;i<points.size();i++)
        {
            for(int j=i+1;j<points.size();j++)
            {
                vector<int>a=points[i];
                vector<int>b=points[j];
                pair<double,double>x=find_m_c(a,b);
                if(temp.find(x)!=temp.end())
                {
                    temp[x].insert(a);
                    temp[x].insert(b);
                }
                else
                {
                    set<vector<int>> s;
                    s.insert(a);
                    s.insert(b);
                    temp[x]=s;
                }
                

            }
        }int ans=0;
        for(auto& x:temp)
        {
            int sum=(x.second).size();
            ans=max(sum,ans);
        }
        return ans;
        
        
    }
};
71266