Easy C++ Solution
\nclass Solution {\npublic:\n    vector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        int n = rooms.size();\n        int
```\nclass Solution {\npublic:\n    vector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        int n = rooms.size();\n        int k = queries.size();\n        vector<int> res(k, -1);\n        for(int i = 0; i < k; i++) {\n            queries[i].push_back(i);\n        }\n        sort(rooms.begin(), rooms.end(), [](vector<int> &a, vector<int> &b){\n            return a[1] > b[1];\n        });\n        sort(queries.begin(), queries.end(), [](vector<int> &a, vector<int> &b){\n            return a[1] > b[1];\n        });\n        set<int> st;\n        int i = 0, j = 0;\n        while(i <= n) {\n            int val = i == n ? INT_MIN : rooms[i][1];\n            while(j < k && queries[j][1] > val) {\n                int ans = -1;\n                int d = INT_MAX;\n                int id = queries[j][0];\n                auto it = st.upper_bound(id);\n                if(it != st.end()) {\n                    if(d > (*it-id)) {\n                        ans = *it;\n                        d = *it-id;\n                    }\n                }\n                if(it != st.begin()) {\n                    it--;\n                    if(d >= (id-*it)) {\n                        ans = *it;\n                    }\n                }\n                res[queries[j][2]] = ans;\n                j++;\n            }\n            if(i == n) break;\n            while(i < n && rooms[i][1] == val) {\n                st.insert(rooms[i][0]);\n                i++;\n            } \n        }\n        return res;\n    }\n};\n```
['C', 'Sorting', 'Ordered Set']