class Solution {
public:
bool isReflected(vector<pair<int, int>>& points) {
unordered_map<int, vector<double>> pts;
double midp = .0, minv = INT_MAX, maxv = INT_MIN;
for (auto &p:points){
pts[p.second].push_back(p.first);
minv = min(minv, (double)p.first), maxv = max(maxv, (double)p.first);
}
midp = (minv+maxv)/2.0;
for (auto &p:pts) {
unordered_set<double> dist;
for (int i:p.second) {
dist.insert(imidp);
}
while (!dist.empty()) {
double d = *dist.begin();
if (dist.find(d) != dist.end()) {
dist.erase(d); dist.erase(d);
}
else return false;
}
}
return true;
}
};
c++ with normal array operation 36ms


@wrbuaa2005 yeah you are right, thanks for pointing it out! I have updated the post, the run time is 45ms now