Company: Amazon_24feb
Difficulty: medium
In Amazon's Elastic Container Service (ECS), tasks are scheduled and managed dynamically. You are given an array resourceConsumption of n integers, where each element represents the resource consumption of a specific task in the system. To optimise system load and clear tasks efficiently, the following termination process is applied repeatedly until no tasks remain: In each iteration, select the task with the lowest resource consumption. Remove that task and its adjacent tasks from the array (if any). The task is to compute the total resource consumption of all the selected tasks — i.e., the tasks with the minimum resource usage in each iteration. Note: If there is more than one task with the same lowest resource consumption, select the task with the smallest index. Example n = 4 resourceConsumption = [4, 3, 2, 1] Simulating the defined operation: Initial resourceConsumption = [4, 3, 2, 1]. Select the task with the lowest resource consumption value (1) and discard it along with i