Monsanto declare Share buyback# Stock
a*e
1 楼
平时几乎不用c++,有没有哪位同学帮看看怎么能让这段程序通过编译?我觉得自己思
路是对了的,不知道如果面试中碰到这种情况是否影响?没觉得哪里template用错了啊
?多谢
主要是在
Point x(a,b);
std::map::iterator it=mp.find(x);
if (it==mp.end())
mp.insert(std::pair(x,1));
else
mp[x]++;
/**
* 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 &points) {
int n=points.size();
if (n==0) return 0;
int a=0,b=0;
map mp;
for (int i=0; i {
for (int j=i+1;j {
a=(points[j].y-points[i].y)/(points[j].x-points[j].x);
b=points[j].y-(points[i].y-points[j].y)*points[j].x/(points[
i].x-points[j].x);
Point x(a,b);
std::map::iterator it=mp.find(x);
if (it==mp.end())
mp.insert(std::pair(x,1));
else
mp[x]++;
}
}
int res=-1;
for(auto it = mp.begin(); it != mp.end(); it++)
{
if (it->second>res)
{
res=it->second;
}
}
return res;
}
};
路是对了的,不知道如果面试中碰到这种情况是否影响?没觉得哪里template用错了啊
?多谢
主要是在
Point x(a,b);
std::map
if (it==mp.end())
mp.insert(std::pair
else
mp[x]++;
/**
* 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
int n=points.size();
if (n==0) return 0;
int a=0,b=0;
map
for (int i=0; i
for (int j=i+1;j
a=(points[j].y-points[i].y)/(points[j].x-points[j].x);
b=points[j].y-(points[i].y-points[j].y)*points[j].x/(points[
i].x-points[j].x);
Point x(a,b);
std::map
if (it==mp.end())
mp.insert(std::pair
else
mp[x]++;
}
}
int res=-1;
for(auto it = mp.begin(); it != mp.end(); it++)
{
if (it->second>res)
{
res=it->second;
}
}
return res;
}
};