C++✅✅ | Custom Sort | Easy Solution | Clean Code |
\n\n# Code\n\n\nclass Solution {\npublic:\n\nstatic bool cmp(vector<int>&v1, vector<int>&v2)\n{\n        return v1[1] - v1[0] > v2[1] - v2[0];\n}\n\n    int min
\n\n# Code\n```\n\nclass Solution {\npublic:\n\nstatic bool cmp(vector<int>&v1, vector<int>&v2)\n{\n        return v1[1] - v1[0] > v2[1] - v2[0];\n}\n\n    int minimumEffort(vector<vector<int>>& tasks) {\n\n        \n       sort(tasks.begin(),tasks.end(),cmp);\n\n       int ans = tasks[0][1];\n       int temp = ans - tasks[0][0];\n\n      \n       for(int i = 1; i < tasks.size(); ++i)\n       {\n           if(temp < tasks[i][1])\n           {\n             ans += tasks[i][1] - temp;\n             temp = tasks[i][1] - tasks[i][0];\n           } \n           else temp -= tasks[i][0];\n       }\n       \n\n       return ans;\n    }\n};\n\n\n```
['C++']