C++ | Binary search
\nvector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        \n      int i=0;\n      int n=rooms.size();\n      int m=queries.
```\nvector<int> closestRoom(vector<vector<int>>& rooms, vector<vector<int>>& queries) {\n        \n      int i=0;\n      int n=rooms.size();\n      int m=queries.size();\n      for(auto &x:queries){\n        x.push_back(i);\n        i++;\n      }\n      \n      sort(begin(rooms),end(rooms),[](const vector<int>&v1,const vector<int>&v2){\n        return v1[1]>v2[1];   \n      });\n      \n      sort(begin(queries),end(queries),[](const vector<int>&v3,const vector<int>&v4){\n        return v3[1]>v4[1]; \n      });\n      \n      i=0;\n      vector<int>res(m,-1);\n      set<int>s;\n      for(auto &y : queries){\n        while(i<n&& rooms[i][1]>= y[1]){\n          s.insert(rooms[i][0]);\n          i++;\n        }\n        auto it = s.lower_bound(y[0]);\n        if(it!=s.end()){ \n        res[y[2]] =*it;\n        }\n\t\t//if no lower bound and set size>0 take the last set element \n        if(it==s.end() && s.size()>0){\n          it--;\n          res[y[2]]=*it;\n          continue;    \n        }\n        //suppose searching for  5 and set currently has elements 4,7,8 lower bound will point at 7 but abs(4-5)<(7-5) so we need to check 1 element before also\n        int diff= abs(*it-y[0]);\n        if(it!=begin(s)){\n          it--;\n          if(abs(*it-y[0])<=diff){\n            res[y[2]]=*it;\n          }\n          \n        }\n        \n      }\n      \n      \n      return res;\n      \n      \n      \n    }\n\n```
['C', 'Binary Tree']