Nykaa Beauty Box Customization
Nykaa aims to offer highly personalized beauty experiences. One such initiative is the "Curated Beauty Box", where customers can select products to build a custom box. To ensure a premium experience while managing inventory and costs, there are specific constraints on each box. This problem focuses on optimizing product selection for a customer's beauty box.
You are tasked with implementing a function maximizeBeautyBoxValue that determines the maximum total beauty score of products that can be included in a customer's beauty box. You must select products such that:
maxBudget.maxItems.Input:
products: An array of objects, where each object has two properties: price (number) and beautyScore (number).maxBudget: A number representing the maximum total price allowed for products in the box.maxItems: A number representing the maximum number of products allowed in the box.Output:
beautyScore achievable under the given constraints.price and beautyScore values will be non-negative integers. maxBudget and maxItems will be non-negative integers.products array can be empty.Examples
Example 1
Input:
products = [{price: 10, beautyScore: 60}, {price: 20, beautyScore: 100}, {price: 30, beautyScore: 120}], maxBudget = 50, maxItems = 2
Output:
220
Note:
Select products with prices 20 and 30. Total price = 50, total items = 2, total beauty score = 100 + 120 = 220. Other combinations like (10, 20) give 160, (10, 30) give 180. Selecting all three exceeds maxItems.
Example 2
Input:
products = [{price: 5, beautyScore: 10}, {price: 8, beautyScore: 12}, {price: 3, beautyScore: 5}], maxBudget = 10, maxItems = 1
Output:
12
Note:
Only one item can be selected. The product with price 8 and beauty score 12 gives the maximum beauty score within budget.
Example 3
Input:
products = [{price: 100, beautyScore: 500}], maxBudget = 50, maxItems = 1
Output:
0
Note:
The only product exceeds the maxBudget, so no products can be selected.
Constraints
1 <= products.length <= 1000 <= products[i].price <= 1000 <= products[i].beautyScore <= 10000 <= maxBudget <= 10000 <= maxItems <= 100Loading editor...