Easy  and simple approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach : Prefix and Binary\n Describe your approach to solving the problem. \n\n#
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : Prefix and Binary\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn+mlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n+m)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\npublic int[] maximumBeauty(int[][] items, int[] queries) {\n    // Sort the items based on price\n        Arrays.sort(items, (a, b) -> Integer.compare(a[0], b[0]));\n        \n        int n = items.length;\n        int[] maxBeauty = new int[n];\n        int[] prices = new int[n];\n        \n        // Fill maxBeauty with the maximum beauty seen so far and prices with item prices\n        maxBeauty[0] = items[0][1];\n        prices[0] = items[0][0];\n        \n        for (int i = 1; i < n; i++) {\n            prices[i] = items[i][0];\n            maxBeauty[i] = Math.max(maxBeauty[i - 1], items[i][1]);\n        }\n        \n        // Array to store the results for the queries\n        int m = queries.length;\n        int[] answer = new int[m];\n        \n        // For each query, find the maximum beauty with price <= query using binary search\n        for (int i = 0; i < m; i++) {\n            int idx = binarySearch(prices, queries[i]);\n            if (idx == -1) {\n                answer[i] = 0;  // No item has price <= queries[i]\n            } else {\n                answer[i] = maxBeauty[idx];  // Maximum beauty up to price queries[i]\n            }\n        }\n        \n        return answer;\n    }\n\n    // Binary search to find the largest price <= target\n    private int binarySearch(int[] prices, int target) {\n        int low = 0, high = prices.length - 1;\n        int result = -1;\n        \n        while (low <= high) {\n            int mid = low + (high - low) / 2;\n            if (prices[mid] <= target) {\n                result = mid;  // Save the index of this valid price\n                low = mid + 1;  // Try to find a larger price within the limit\n            } else {\n                high = mid - 1;\n            }\n        }\n        \n        return result;\n}\n}\n```
['Array', 'Binary Search', 'Sorting', 'Prefix Sum', 'Java']