Java | Greedy approach with sorting O(nlogn)
\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks, (t1, t2) -> (t2[1]-t2[0]) - (t1[1]-t1[0]));\n        int initial =
```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks, (t1, t2) -> (t2[1]-t2[0]) - (t1[1]-t1[0]));\n        int initial = 0, current = 0;\n        for (int[] task : tasks) {\n            if (current < task[1]) {\n                initial += task[1] - current;\n                current = task[1];\n            }\n            current -= task[0];\n        }\n        return initial;\n    }\n}\n```
['Greedy', 'Sorting', 'Java']