price is key..beauty is value....hello again hashmaps!!
Intuition\nFigured that for a corresponding price let\'s just store the max value of the key(less than equal to) in the map.\n\n# Approach\nIntution was correct
# Intuition\nFigured that for a corresponding price let\'s just store the max value of the key(less than equal to) in the map.\n\n# Approach\nIntution was correct, I managed to make a map that could give me the best beauty value for a key and rest was just plain binary search. Hashtables are too valuable!!\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& queries) \n    {\n        unordered_map<int,int> a;\n        vector<int> b;\n        int n=items.size();\n        sort(items.begin(),items.end());\n        int m=0;\n        for(int i=0;i<n;i++)\n        {\n            b.push_back(items[i][0]);\n            m=max(m,items[i][1]);\n            a[items[i][0]]=max(m,items[i][1]);\n        }\n        vector<int> ans;\n        for(int i=0;i<queries.size();i++)\n        {\n            int l=0,u=n-1,res=0;\n            while(l<=u)\n            {\n                int mid=l+(u-l)/2;\n                if(b[mid]>queries[i])\n                {\n                    u=mid-1;\n                }\n                else if(b[mid]<=queries[i])\n                {\n                    l=mid+1;\n                    res=max(res,a[b[mid]]);\n                }\n            }\n            ans.push_back(res);\n        }\n        return ans;\n\n    }\n};\n```
['Array', 'Hash Table', 'Binary Search', 'Sorting', 'C++']