[JAVA] BEATS 100.00% MEMORY/SPEED 0ms // APRIL 2022
\nclass Solution {\n    public int[] maximumBeauty(int[][] items, int[] queries) {\n        int n = queries.length, m = items.length;\n        Arrays.sort(items
```\nclass Solution {\n    public int[] maximumBeauty(int[][] items, int[] queries) {\n        int n = queries.length, m = items.length;\n        Arrays.sort(items, Comparator.comparingInt(o -> o[0]));\n        int[] ans = new int[n];\n\n        for (int i = 0; i < m; i++)\n            items[i][1] = Math.max(items[i][1], items[i > 0? i - 1 : 0][1]);\n\n        int j = 0;\n        for (int q : queries){\n            int lo = -1, hi = m - 1; //pad lo = -1 to mark no result\n            while(lo < hi){\n                int mid = lo + (hi - lo) / 2 + 1;\n                if (q >= items[mid][0]) lo = mid;\n                else hi = mid - 1;\n            }\n            ans[j++] = lo == -1? 0 : items[lo][1];\n        }\n\n        return ans;\n    }\n}\n```\n\n***Consider upvote if usefull!***
['Java']