Company: IBM_11dec
Difficulty: medium
Select Least Resource Tasks Select Least Resource Tasks Description In a task scheduling system, you are given an array of n integers resourceConsumption , where each integer represents the resource consumption value of a task. The objective is to perform the following operation until no tasks are left. In each iteration: Select the task with the lowest resource consumption from the current list of tasks. Remove the selected task along with its adjacent tasks from the list. Implement a function that computes and returns the total resource consumption of all the tasks selected during this process. Note: If there is more than 1 task with the same lowest resource consumption, then select the task with the smallest index in the current list. Example 1 Input: resourceConsumption = [4, 3, 2, 1] Output: 4 Explanation: Simulating the defined operation: 1. The list is [4, 3, 2, 1] . The lowest resource consumption is 1 (at index 3). Select it. Remove the selected task (1) and its adjacent task