https://leetcode.com/problems/best-time-to-buy-and-sell-stock/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int ans = 0;
        int mn = INT_MAX / 2;
        for (auto &x: prices) {
            ans = max(ans, x - mn);
            mn = min(mn, x);
        }
        return ans;
    }
};

Time Complexity: O(n)
Space: O(1)

挺無聊的