Easy JAVA Solution | O(n logn) | Sorting
Easy to understand Java Solution\nSorting on the basis of MAXIMUM Difference between the Minimum And Actual Energy Requirements\n\n\nclass Solution {\n    publi
Easy to understand Java Solution\nSorting on the basis of MAXIMUM Difference between the Minimum And Actual Energy Requirements\n\n```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        int tot=0; // total effort required\n        for(int[] t:tasks){\n            tot+=t[0];\n        }\n        int res=tot; // the result to be returned\n        int rem=tot; // a temporary variable to keep track of our expenses\n        Arrays.sort(tasks, (a,b)->(b[1]-b[0])-(a[1]-a[0]));\n        for(int[]t:tasks){\n            if(t[1]>rem){\n                int val=t[1]-rem;\n                res+=val;\n                rem+=val;\n            }\n            rem-=t[0];\n        }\n        return res;\n    }\n}\n```
['Array', 'Greedy', 'Sorting', 'Java']