Java - with simple idea explanation
\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        \n        /*\n        Idea - finding the minimum initial energy to finish tasks\n    
```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        \n        /*\n        Idea - finding the minimum initial energy to finish tasks\n        \n        -> finish tasks which can induce max residual energy after completion\n        eg - [5,10] over [10,10] since former can carry over energy\n        and total initial energy will be - 10 +5 = 15 \n        \n        if we do the other way \n        [10,10] [5,10] - initial energy will be 10 + 10 = 20\n        \n        -> if two tasks have same residual energy, order doesnt matter since the carry over is going to be same irrespective\n        \n        */\n        \n        Arrays.sort(tasks,(a,b)->{\n            int diff = (b[1]-b[0]) - (a[1]-a[0]);\n            return diff;\n        });\n        \n        int initial = 0;\n        int power = 0;\n        \n        // iterate the sorted tasks\n        for(int i=0;i<tasks.length;i++)\n        {\n              // if existing power is less than min required - add to inital energy to supplement it from start\n              if(power < tasks[i][1])\n              {\n                  // difference requied to smoothly execute this task in ideal case\n                  initial+=tasks[i][1]-power;\n                  \n                  // now power is restored to min requied\n                  power = tasks[i][1];\n              }\n            \n              // consume the energy for the task\n              power-=tasks[i][0];\n        }\n        return initial;\n    }\n}\n```
['Java']