Company: Amazon_17feb
Difficulty: medium
Code Question 1 Problem Description In Amazon's Elastic Container Service (ECS), tasks are scheduled and managed dynamically. You are given an array resourceConsumption of n integers, where each integer represents the resource consumption of a specific task in the system. To optimize 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. Function Description The function selectLeastResourceTasks takes the following input: int resourceConsumption[n] : each integer represents the resource consumption of a task. Returns int