Final answer:
To solve this problem, iterate through the products array and keep track of the minimum weight encountered so far. At each iteration, add the minimum weight to the total sum and update the minimum weight if a lighter product is found. Repeat until the end of the array. The final sum is the answer.
Step-by-step explanation:
In this problem, Alice is selecting three adjacent products at a time, starting with the lightest product and removing it along with the two adjacent products. The goal is to find the sum of the weights of the lightest products chosen at each selection. To solve this problem, we can iterate through the products array and keep track of the minimum weight encountered so far. At each iteration, we add the minimum weight to the total sum and update the minimum weight if we encounter a lighter product. We repeat this process until we reach the end of the array. The final sum will be the answer.
For example, given an array of products with weights [4,3,2,1], we start by choosing the product with weight 1. The array becomes [4,3]. Then, we choose the product with weight 3. The array becomes empty. The sum is 1+3 = 4.