lazy but crazy
Intuition\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 
# Intuition\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```\n/**\n * @param {number[][]} transactions\n * @return {number}\n */\nvar minimumMoney = function(t) {\n    let top=[], bottom=[]\n    for (let i=0;i<t.length;i++){\n        if (t[i][1]<t[i][0]) top.push(t[i])\n        else bottom.push(t[i])   \n    }\n    top.sort((a,b)=>a[1]-b[1])\n    bottom.sort((a,b)=>b[0]-a[0])\n    let arr=[...top,...bottom]\n    for (let i=arr.length-2;i>-1;i--){\n        if (arr[i][0]-arr[i][1]>0 )\n            if(arr[i][0]<arr[i+1][0]+arr[i][0]-arr[i][1]){\n            arr[i][0]=arr[i+1][0]+arr[i][0]-arr[i][1]\n            }\n    }\n    return arr[0][0]\n};\n```
['Array', 'Greedy', 'Sorting', 'JavaScript']