Java || Easy
\n\n# Code\njava []\nclass Solution {\n    public int[] maximumBeauty(int[][] items, int[] queries) {\n        Arrays.sort(items,(a,b)->a[0]-b[0]);\n        int
\n\n# Code\n```java []\nclass Solution {\n    public int[] maximumBeauty(int[][] items, int[] queries) {\n        Arrays.sort(items,(a,b)->a[0]-b[0]);\n        int n=items.length;\n        int[] maxbeauty=new int[n];\n        maxbeauty[0]=items[0][1];\n        for(int i=1;i<n;i++){\n            maxbeauty[i]=Math.max(maxbeauty[i-1],items[i][1]);\n        }\n        for(int i=0;i<queries.length;i++){\n            int q=queries[i];\n            int left=0;int right=n-1;\n            while (left <= right) {\n                int mid = left + (right - left) / 2;\n                if (items[mid][0] <= q) {\n                    left = mid + 1;\n                } else {\n                    right = mid - 1;\n                }\n            }if(right>=0){queries[i]=maxbeauty[right];}\n            else{queries[i]=0;}\n        }\n        return queries;\n    }\n}\n```
['Java']