C++ simple solution


  • 0
    class Solution {
    public:
        bool isReflected(vector<pair<int, int>>& points) {
            map<int, set<int>> mp;
            int left = INT_MAX, right = INT_MIN;
            for (auto i : points) {
                mp[i.second].insert(i.first);
                if (i.first > right)
                    right = i.first;
                if (i.first < left)
                    left = i.first;
            }
            
            for (auto i : points) {
                int oppo = left + right - i.first;
                if (mp[i.second].find(oppo) == mp[i.second].end())
                    return false;
            }
            return true;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.