JAVA 90% FAST SIMPLE SOLUTION WITH EXPLANATION  WITH TIME AND SPACE
EXPLANATION:\n  required will be minimum if first we choose:\n     1.task with minimum consumption.\n     2.task with maximum initial requirement.\nBUT, both ar
EXPLANATION:\n  required will be minimum if first we choose:\n     1.task with minimum consumption.\n     2.task with maximum initial requirement.\nBUT, both are opposite task so we will sort task based on difference b/w initial requirement and consumption. if its same than based on maximum requirement if its also same than based on minimum consumption.\n  JAVA CODE IS:\n```\nclass Solution {\n    public int minimumEffort(int[][] tasks) {\n\t//SORTING THE TASKS\n     Arrays.sort(tasks,(a,b) ->\n         (b[1]-b[0])!=(a[1]-a[0])? ((b[1]-b[0])-(a[1]-a[0])) : b[1]!=a[1] ? b[1]-a[1] : b[0]-a[0]);\n         int min=0;\n        for(int a[] : tasks){\n           //System.out.println(a[0]+"  "+a[1]);\n            min+=a[0];\n        }\n        int ans=min;\n        for(int a[] : tasks){\n            if(a[1]>min){\n                ans+=(a[1]-min);\n            min+=(a[1]-min);\n            }\n                min-=a[0];\n        }\n             return ans;\n    }\n}\n```\nTime:  O(nlogn)+O(n)+O(n)=O(nlogn)\nSpace: O(1) no extra space is used\n***IF THIS IS REALLY HELPFUL FOR YOU PLEASE UPVOTE***
[]