Answered step by step
Verified Expert Solution
Question
1 Approved Answer
There are n chocolates and the weight of the chocolates is given as an array of integers weights/n, where weights] denote the weight of
There are n chocolates and the weight of the chocolates is given as an array of integers weights/n, where weights] denote the weight of the chocolate. Every day, one can pick one chocolate, eat half of it, and put the remaining half back. Find the minimum possible total weight of the remaining chocolates after a days. Note that one can eat the same chocolate multiple times. The weight of the part eaten can be calculated as floor(weights/12) Example: chocolates [30, 20, 251 d=4 Day 1 2 3 4 Weight of the chocolate picked 20 Constraints tenx10 Is weights 10 where in 1 210 25 30 15 Weight Remaining weight eaten 10 12 15 7 10 13 15 8 findMinWeight has the following parameters: int weightsin an array of integers representing weights of chocolates, indexed 0 to 1 int d an integer representing the number of days Returns int: the minimum total weight of chocolates after of days Result [30,10,25] (30,10, 13] The total weight of chocolates on day 4 is 8-10-13, which is the minimum pessible weight after 4 days. Function Description Complete the function findMinWeight in the editor below. [15,10,13] [8, 10, 13)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To solve this problem we want to minimize the total weight of chocolates after a given number of day...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started