✅ Simple Java Solution
CODE\nJava []\npublic int[] maximumBeauty(int[][] items, int[] queries) {\n\tint n = items.length;\n\tArrays.sort(items, (a,b)->{\n\t\tif(a[0] == b[0]) return b
## **CODE**\n```Java []\npublic int[] maximumBeauty(int[][] items, int[] queries) {\n\tint n = items.length;\n\tArrays.sort(items, (a,b)->{\n\t\tif(a[0] == b[0]) return b[1]-a[1];\n\t\treturn a[0]-b[0];\n\t});\n\n\tfor(int i=1; i<n; i++) {\n\t\titems[i][1] = Math.max(items[i-1][1], items[i][1]);\n\t}\n\n\tint res[] = new int[queries.length];\n\tfor(int i=0; i<queries.length; i++) {\n\t\tint l = 0, r = n-1;\n\t\twhile(l <= r) {\n\t\t\tint mid = l + (r-l)/2;\n\t\t\tif(items[mid][0] <= queries[i]) {\n\t\t\t\tres[i] = items[mid][1];\n\t\t\t\tl = mid+1;\n\t\t\t} else {\n\t\t\t\tr = mid-1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn res;\n}\n```
['Sorting', 'Binary Tree']