[C++] || Map - Multiset || Simple - Easy to Understand
class Solution {\npublic:\n  \n    \n    vector maximumBeauty(vector>& items, vector& v) {\n        mapm;\n        sort(items.begin(), items.end());\n        in
class Solution {\npublic:\n  \n    \n    vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& v) {\n        map<int,int>m;\n        sort(items.begin(), items.end());\n        int max_val = 0;\n        for(int i=0;i<items.size();i++){\n            int s= items[i][0];\n            int d = items[i][1];\n            max_val = max(max_val , d);  /// store the max_val , at that point\n            m[s] = max(m[s] , max_val);  \n        }\n        \n        multiset <int, greater <int> > iammultiset;\n        for(auto i : m){\n             iammultiset.insert(i.first);\n        }\n        \n        for(int i=0;i<v.size();i++){\n            if(m.find(v[i])!=m.end()){  // if v[i] is present in map , simply that number will be maximum\n                v[i]  = m[v[i]];\n            }\n            else{   /// else the maximum will me lower_bound of v[i] in map \n                v[i] = m[ *iammultiset.lower_bound(v[i]) ];\n            }\n        }\n        \n        return v;\n        \n    }\n};
[]