java solution with binary search(80.32% faster)
\nclass Solution {\n   public int[] maximumBeauty(int[][] items, int[] queries) {\n        int m = items.length;\n        Arrays.sort(items, (a, b) -> Double.co
```\nclass Solution {\n   public int[] maximumBeauty(int[][] items, int[] queries) {\n        int m = items.length;\n        Arrays.sort(items, (a, b) -> Double.compare(a[0], b[0]));\n        int n = queries.length;\n        int[] mxLeft = new int[m];\n\n        mxLeft[0]= items[0][1];\n        for(int i=1;i<m;i++)\n            mxLeft[i] = Math.max(mxLeft[i-1],items[i][1]);\n\n        int[] ans = new int[n];\n        for(int i=0;i<n;i++){\n            int curr= queries[i];\n            int l=0,r=m-1;\n            int profit = -1;\n\n            while(l<=r){\n                int mid = l+(r-l)/2;\n                if(items[mid][0]>curr){\n                    r=mid-1;\n                }\n                else{\n                    profit=mid;\n                    l=mid+1;\n                }\n            }\n            if(profit==-1) continue;\n            ans[i]=mxLeft[profit];\n        }\n\n\n        return ans;\n    }\n}\n```
[]