标签:pre image 最大利润 面试 price com strong 面试题 col
题目:
解答:
1 class Solution { 2 public: 3 int maxProfit(vector<int>& prices) 4 { 5 int cost = INT_MAX; 6 int profit = 0; 7 for (int price: prices) 8 { 9 cost = std::min(cost, price); 10 profit = std::max(profit, price - cost); 11 } 12 13 return profit; 14 15 } 16 };
标签:pre image 最大利润 面试 price com strong 面试题 col
原文地址:https://www.cnblogs.com/ocpc/p/12859851.html