Leetcode 122. 买卖股票的最佳时机 II 解题思路及C++实现

解题思路:code 采用贪心策略,只要后一天的价格高于前一天,就将差价加进来。获得的结果就是能获取的最大利润。it   class Solution { public: int maxProfit(vector<int>& prices) { //输入为空 if(prices.empty()) return 0; int r
相关文章
相关标签/搜索