Simple and easy java solution
Intuition\nThe code is a method designed to find the maximum beauty of items that can be purchased within a given budget defined by the queries. Each item has a
# Intuition\nThe code is a method designed to find the maximum beauty of items that can be purchased within a given budget defined by the queries. Each item has a price and a beauty value, and the goal is to return an array of maximum beauty values corresponding to each query.\n\n# Approach\nThe items are sorted in descending order based on their beauty value \n****(b[1] - a[1])**.** This means that the item with the highest beauty will be considered first. \n\nans[] is an integer array initialized to store the final answer.\nThe outer loop iterates over each query in the queries array.\n******## **max** is initialized to zero for each query.******\n\nThe inner loop iterates over all items to find the first item whose price (items[j][0]) is less than or equal to the current query value (queries[i]).\nIf such an item is found, max is updated to the beauty of that item (items[j][1]), and the loop is exited with break.\n\n# After checking all items for the current query, the value of max is stored in the ans array at index i.\n\nFinally, return the ans array.\n\n- Time complexity:\nO(N^2)\n\n- Space complexity:\nO(N)\n\n# Code\n```java []\nclass Solution {\n    public int[] maximumBeauty(int[][] items, int[] queries) {\n        Arrays.sort(items, (a, b) -> b[1] - a[1]);\n        int m = queries.length;\n        int ans[] = new int[m];\n        for (int i = 0; i < queries.length; i++) {\n            int max = 0;\n            for (int j = 0; j < items.length; j++) {\n                if (items[j][0] <= queries[i]) {\n                    max = items[j][1];\n                    break;\n                }\n            }\n            ans[i] = max;\n        }\n        return ans;\n    }\n}\n```
['Java']