[C] | Solution with comments and description
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nAs our aim is to use as
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nAs our aim is to use as little starting energy as possible, as little energy as possible must be left over after the last task has been completed. This specifically means that the last task performed must have the smallest difference between \'minimum\' and \'actual\'.\n\nStep 1 follows from this: Sort the array according to \'minimum\' - \'actual\'.\n## Let us now start at index 0: \nIt is known that you need at least tasks[0][1] energy to execute the task -> start value of our energy counter\n\n## Continue with index 1:\nSince we lose at least task[1][0] energy when performing task[1], we add this to our energy counter. However, if this value is below the minimum task[1][1], the task cannot be started and the energy before the task must therefore be tasks[1][1].\n\n## Next\nThis process is now applied to the entire array.\n\nTranslated with DeepL.com (free version)\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint compare(const void *a, const void *b) {\n    const int **ia = (const int **)a;\n    const int **ib = (const int **)b;\n\n    return ((*ia)[1] - (*ia)[0]) - ((*ib)[1]-(*ib)[0]);\n}\n\nint minimumEffort(int** tasks, int tasksSize, int* tasksColSize) {\n    int ans;\n\n    //Sorts the Array by minimum-actual\n    qsort(tasks, tasksSize, sizeof(tasks[0]), compare);\n\n    //starting value at index 0\n    ans = tasks[0][1];\n\n    for (int i = 1; i < tasksSize; ++i) {\n        if (ans + tasks[i][0] >= tasks[i][1]) {\n            //Adding the required Energy for the i\'th task is bigger than the minimum required to start this task\n            ans += tasks[i][0];\n        }\n        else{\n            //Adding the required Energy for the i\'th task is smaller than the minimum required to start this task\n            ans = tasks[i][1];\n        }\n    }\n    return ans;\n}\n```
['C']