Go solution. O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal of this function is to find the minimum amount of money that needs to be paid 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal of this function is to find the minimum amount of money that needs to be paid in order to make all transactions "good". A transaction is good if the amount received is greater than or equal to the amount spent.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach taken in this function is to first separate the transactions into two lists: "good" transactions and "bad" transactions. A "good" transaction is one where the amount received is greater than or equal to the amount spent, and a "bad" transaction is one where the amount received is less than the amount spent.\n\nOnce the transactions are separated, the function calculates the minimum amount of money needed to make the "bad" transactions good. This is done by adding up the difference between the amount received and the amount spent for each "bad" transaction, and also keeping track of the maximum amount spent in any "bad" transaction.\n\nFinally, the function looks at the "good" transactions and keeps track of the maximum amount received in any "good" transaction.\n\nThe minimum amount of money needed to make all transactions good is then calculated by adding the sum of the differences between the amounts received and spent for the "bad" transactions, and the maximum amount received or spent in either the "good" or "bad" transactions.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of this function is O(n), where n is the number of transactions. This is because the function only needs to iterate through the transactions once in order to separate them into "good" and "bad" lists, and then again in order to calculate the minimum amount of money needed to make all transactions good.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity of this function is also O(n), as it creates two lists (one for "good" transactions and one for "bad" transactions) that have a size equal to the number of transactions.\n# Code\n```\nfunc minimumMoney(transactions [][]int) int64 {\n    good, bad := [][]int{}, [][]int{}\n    for _, t := range transactions {\n        c, g := t[0], t[1]\n        if c > g {\n            bad = append(bad, []int{c, g})\n        } else {\n            good = append(good, []int{c, g})\n        }\n    }\n    base, extra := 0, 0\n    for _, b := range bad {\n        base += b[0] - b[1]\n        extra = max(extra, b[1])\n    }\n    for _, g := range good {\n        extra = max(extra, g[0])\n    }\n    return int64(base + extra)\n}\n\nfunc max(a, b int) int {\n    if a > b {\n        return a\n    }\n    return b\n}\n\n```
['Go']