121. Best Time to Buy and Sell Stock

来源:互联网 发布:淘宝推广有效方法 编辑:程序博客网 时间:2024/06/10 17:04

这里写图片描述

    int maxProfit(vector<int>& prices) {        int res=0,buy=INT_MAX;        for(int price:prices){            buy=min(buy,price);            res=max(res,price-buy);        }        return res;    }
原创粉丝点击