SIMPLE FAST SOLUTION BEATS 95%+ OF ALL USERS ON RUNTIME COMPLEXITY 🔥🔥🔥💯💯💯
\n# Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n-
![image.png](https://assets.leetcode.com/users/images/cc491ed4-3d37-4e11-8de5-baccdac3e5c0_1712788237.9625502.png)\n# Intuition\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minimumMoney(self, transactions: List[List[int]]) -> int:\n        loss = []\n        win = []\n        for t in transactions:\n            if t[0]-t[1] > 0:\n                loss.append(t)\n            else:\n                win.append(t)\n        loss = sorted(loss, key=lambda x: x[1])\n        win = sorted(win, key=lambda x: x[0], reverse=True)\n        loss += win\n        s = 0\n        m = 0\n        for l in loss:\n            s += l[0]\n            if s > m:\n                m = s\n            s -= l[1]\n        return m\n```
['Python3']