Java sort by (minimum-actual)
```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks,(a,b)->(b[1]-b[0])-(a[1]-a[0]));\n        int energy=0;\n       
```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks,(a,b)->(b[1]-b[0])-(a[1]-a[0]));\n        int energy=0;\n        int ans=0;\n        for(int i=0;i<tasks.length;i++){\n            if(energy<tasks[i][1]){\n                int req=tasks[i][1]-energy;\n                energy+=req;\n                ans+=req;\n            }\n            energy-=tasks[i][0];\n        }\n        return ans;\n    }\n}
[]