[C++] Sorted  the Queries and Rooms . Still Getting TLE , plz review the code
\nset<int>st;\nclass Solution {\npublic:\n    vector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        sort(rooms.begin(),ro
```\nset<int>st;\nclass Solution {\npublic:\n    vector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        sort(rooms.begin(),rooms.end(),[&](vector<int>p,vector<int>q){\n            return p[1]>q[1];\n        });\n        int n=queries.size();\n        vector<int>ans(n);\n        int ix=0;\n        for(vector<int>&v:queries) {\n            v.push_back(ix++);\n        }\n        sort(queries.begin(),queries.end(),[&](vector<int>p,vector<int>q){\n            return p[1]>q[1];\n        });\n        ix=0;\n        st.clear();\n        for(vector<int>v:queries) {\n            while(ix<rooms.size() && rooms[ix][1]>=v[1]) {\n                st.insert(rooms[ix][0]);\n                ix+=1;\n            }\n            int cid=v[0];\n            if(st.size()==0) ans[v[2]]=-1;\n            else {\n                auto it = st.lower_bound(cid);\n                int re=INT_MAX,rix=-1;\n                if(it==st.end()) {\n                    ans[v[2]]=*st.rbegin();\n                }\n                else {\n                    int diff = *it-cid;\n                    if(re>diff){\n                        re=diff;\n                        rix=*it;\n                    }\n                    if(it!=st.begin()) {\n                        it--;\n                        diff=cid-*it;\n                        if(re>=diff) re=diff, rix=*it;\n                        \n                    \n                    }\n                    ans[v[2]]=rix;\n                }\n            }\n        }\n        return ans;\n    }\n};\n```
[]