Python Binary Search
Pick those task first which are trying hard to show off.\nMeans abs(min-actual)\n\n\nclass Solution:\n    def isPossible(self, tasks, energy):\n        for task
Pick those task first which are trying hard to show off.\nMeans abs(min-actual)\n\n```\nclass Solution:\n    def isPossible(self, tasks, energy):\n        for task in tasks:\n            required,show = task\n            if energy < show or energy < required:\n                return False\n            energy -= required\n        return True\n    \n    def minimumEffort(self, tasks: List[List[int]]) -> int:\n        tasks.sort(key = lambda x : -abs(x[1]-x[0]))\n        left,right = 0,0\n        for task in tasks:\n            left += task[0]\n            right += task[1]\n        result = right\n        while left <= right:\n            mid = (left + right) // 2\n            if self.isPossible(tasks,mid):\n                result = mid \n                right = mid - 1\n            else:\n                left = mid + 1\n        return result\n```
[]