We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7d15e7e commit 395bdd7Copy full SHA for 395bdd7
problems/0122.买卖股票的最佳时机II.md
@@ -190,7 +190,17 @@ class Solution:
190
Go:
191
192
193
-
+Javascript:
194
+```Javascript
195
+// 贪心
196
+var maxProfit = function(prices) {
197
+ let result = 0
198
+ for(let i = 1; i < prices.length; i++) {
199
+ result += Math.max(prices[i] - prices[i - 1], 0)
200
+ }
201
+ return result
202
+};
203
+```
204
205
-----------------------
206
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
0 commit comments