Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int maxPoints(vector<vector<int>>& points) {
- int max_freq = INT_MIN;
- if(points.size() == 1)
- return 1;
- for(int i=1; i<points.size(); i++){
- unordered_map<double, int> A;
- for(int j=0; j<i; j++){
- double slope;
- if(points[j][0] == points[i][0])
- slope = INT_MAX;
- else
- slope = (double)(points[i][1]-points[j][1])/(points[i][0]-points[j][0]);
- A[slope]++;
- max_freq = max(max_freq, A[slope]);
- }
- }
- return max_freq+1;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment