Simplest Code!!!⚡👌
\n\n# Code\n\nclass Solution {\npublic:\n    static bool comp(vector<int>& a,vector<int>& b){\n        return a[1]>b[1];\n    }\n    vector<int> closestRoom(vec
\n\n# Code\n```\nclass Solution {\npublic:\n    static bool comp(vector<int>& a,vector<int>& b){\n        return a[1]>b[1];\n    }\n    vector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        int n=queries.size();\n        for(int i=0;i<queries.size();i++)queries[i].push_back(i);\n        sort(rooms.begin(),rooms.end(),comp);\n        sort(queries.begin(),queries.end(),comp);\n        int i=0;\n        set<int>st;\n        vector<int>ans(n);\n        for(auto q:queries){\n            int qid=q[0];\n            int minsize=q[1];\n            int idx=q[2];\n            while(i<rooms.size() && rooms[i][1]>=minsize){\n                st.insert(rooms[i][0]);\n                i++;\n            }\n            if(st.size()){\n                auto it=st.upper_bound(qid);\n                int res=INT_MAX;\n                int roomid=INT_MAX;\n                if(it!=st.end()){\n                    res=abs(qid-*it);\n                    roomid=*it;\n                }\n               else{\n                   res=INT_MAX;\n                   roomid=*it;\n                }\n                if(it!=st.begin()){\n                    --it;\n                    if(abs(*it-qid)<=res){\n                        res=abs(qid-*it);\n                        roomid=*it;\n                    }\n                }\n                ans[idx]=roomid;\n                idx++;\n            }\n            else{\n                ans[idx]=-1;\n                idx++;\n            }\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'Sorting', 'C++']