Java || Greedy || O(N logN ) time || O(1) space
sort it by difference between minimum energy and needed energy\n```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks,
sort it by difference between minimum energy and needed energy\n```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks,(a,b)->a[1]-a[0]-b[1]+b[0]);\n        int prev=0;\n        for (int[] item:tasks){\n            prev=Math.max(prev+item[0],item[1]);\n        }\n        return prev;\n    }\n}
['Greedy', 'Sorting', 'Java']