EASY AND SIMPLE JAVA SOLUTION (WITH EXPLAINATION).
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n        Arrays.sort(tasks, (a, b) -> Integer.compare(a[1]-a[0], b[1]-b[0]));\n        int ans=tasks[tasks.length-1][1];\n        int diff=tasks[tasks.length-1][1]-tasks[tasks.length-1][0];\n        for(int i=tasks.length-2;i>=0;i--){\n            if(tasks[i][1]>diff){\n                ans=ans+tasks[i][1]-diff;\n                diff=tasks[i][1]-tasks[i][0];\n            }\n            else{\n                diff=diff-tasks[i][0];\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']