Easy C++ solution || Greedy Approach
\n\n# Code\n\nclass Solution {\npublic:\n    static bool cmp(vector<int>& a, vector<int>& b){\n        return (a[1] - a[0]) > (b[1] - b[0]);\n    }\n\n    int m
\n\n# Code\n```\nclass Solution {\npublic:\n    static bool cmp(vector<int>& a, vector<int>& b){\n        return (a[1] - a[0]) > (b[1] - b[0]);\n    }\n\n    int minimumEffort(vector<vector<int>>& tasks) {\n        sort(tasks.begin(), tasks.end(), cmp);\n        int n = tasks.size(), ans = 0, energyLeft = 0;\n        for(int i=0; i<n; i++){\n            int actual = tasks[i][0];\n            int mini = tasks[i][1];\n\n            if(energyLeft < mini){\n                ans += mini - energyLeft;\n                energyLeft = mini - actual;\n            }\n            else{\n                energyLeft = energyLeft - actual;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['Array', 'Greedy', 'Sorting', 'C++']