C++ Understandable Solution
Just add the total actual energy\'s required to get all done, and the minimum difference between the actual and minimum energy required to kick start the proces
* Just add the total actual energy\'s required to get all done, and the minimum difference between the actual and minimum energy required to kick start the process.\n* Another case is where the minimum energy required could be very high, thus we find the maximum of the required energies.\n* Now we return the maximum of the difference values and the max of required energy.\n```\nclass Solution {\npublic:\n    int minimumEffort(vector<vector<int>>& tasks) {\n        int diff=INT_MAX,ans=0;\n        for(auto i : tasks){\n            diff=min(diff,i[1]-i[0]);\n            ans+=i[0];\n        }\n        int val=0;\n        for(auto i : tasks)\n            val=max(val,i[1]);\n        return max(ans+diff,val);\n    }\n};\n```\nUpdate Answer : Sort based on difference and then find the maximum energy required.\n```\nclass Solution {\npublic:\n    int minimumEffort(vector<vector<int>>& tasks) {\n        for(auto &task : tasks)\n            task[0]=task[1]-task[0];\n        sort(tasks.begin(),tasks.end());\n        int res=0;\n        for(auto &task : tasks){\n            int actual=task[1]-task[0];\n            res+=actual;\n            if(task[1]>res)\n                res=task[1];\n        }\n        return res;\n    }\n};\n```
['C']