leetcode 122 . Best Time to Buy and Sell Stock II
Posted Militant_799
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 122 . Best Time to Buy and Sell Stock II相关的知识,希望对你有一定的参考价值。
class Solution { public: int maxProfit(vector<int>& prices) { int local=0,golal = 0; for (int i=0; i<prices.size()-1; i++) { local = max(local + (prices[i+1] - prices[i]), 0); golal = max(golal,local); } cout<<golal<<endl; return golal; } };
以上是关于leetcode 122 . Best Time to Buy and Sell Stock II的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode 122. Best Time to Buy and Sell Stock II
LeetCode OJ 122. Best Time to Buy and Sell Stock II
Java [Leetcode 122]Best Time to Buy and Sell Stock II
122. Best Time to Buy and Sell Stock leetcode解题笔记