[C++] Simple C++ Code || O(NlogN)
\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\n    i
\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\n    int BinarySearch(vector<vector<int>>& items, int q, vector<int> &Beauty)\n    {\n        int start = 0, end = items.size()-1;\n        int val = 0;\n        while(start <= end)\n        {\n            int mid = start + (end-start)/2;\n            if(q >= items[mid][0])\n            {\n                val = Beauty[mid];\n                start = mid+1;\n            }\n            else\n                end = mid-1;\n        }\n        return val;\n    }\npublic:\n    vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& queries) \n    {\n        int n = items.size();\n        sort(items.begin(), items.end());\n        vector<int> ans, mxBeauty(n);\n        mxBeauty[0] = items[0][1];\n        for(int i = 1; i < n; i++)\n        {\n            mxBeauty[i] = max(mxBeauty[i-1],items[i][1]);\n        }\n        for(int &q : queries)\n        {\n            ans.push_back(BinarySearch(items, q, mxBeauty));\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'C', 'Sorting', 'Binary Tree', 'C++']