Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66679d6

Browse files
authored
Update 122.best-time-to-buy-and-sell-stock-ii.md
1 parent 0f9332d commit 66679d6

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

problems/122.best-time-to-buy-and-sell-stock-ii.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -54,62 +54,6 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.
5454
JS Code:
5555

5656
```js
57-
58-
/*
59-
* @lc app=leetcode id=122 lang=javascript
60-
*
61-
* [122] Best Time to Buy and Sell Stock II
62-
*
63-
* https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/
64-
*
65-
* algorithms
66-
* Easy (50.99%)
67-
* Total Accepted: 315.5K
68-
* Total Submissions: 610.9K
69-
* Testcase Example: '[7,1,5,3,6,4]'
70-
*
71-
* Say you have an array for which the i^th element is the price of a given
72-
* stock on day i.
73-
*
74-
* Design an algorithm to find the maximum profit. You may complete as many
75-
* transactions as you like (i.e., buy one and sell one share of the stock
76-
* multiple times).
77-
*
78-
* Note: You may not engage in multiple transactions at the same time (i.e.,
79-
* you must sell the stock before you buy again).
80-
*
81-
* Example 1:
82-
*
83-
*
84-
* Input: [7,1,5,3,6,4]
85-
* Output: 7
86-
* Explanation: Buy on day 2 (price = 1) and sell on day 3 (price = 5), profit
87-
* = 5-1 = 4.
88-
* Then buy on day 4 (price = 3) and sell on day 5 (price = 6), profit = 6-3 =
89-
* 3.
90-
*
91-
*
92-
* Example 2:
93-
*
94-
*
95-
* Input: [1,2,3,4,5]
96-
* Output: 4
97-
* Explanation: Buy on day 1 (price = 1) and sell on day 5 (price = 5), profit
98-
* = 5-1 = 4.
99-
* Note that you cannot buy on day 1, buy on day 2 and sell them later, as you
100-
* are
101-
* engaging multiple transactions at the same time. You must sell before buying
102-
* again.
103-
*
104-
*
105-
* Example 3:
106-
*
107-
*
108-
* Input: [7,6,4,3,1]
109-
* Output: 0
110-
* Explanation: In this case, no transaction is done, i.e. max profit = 0.
111-
*
112-
*/
11357
/**
11458
* @param {number[]} prices
11559
* @return {number}
@@ -137,7 +81,6 @@ class Solution:
13781
gains = [prices[i] - prices[i-1] for i in range(1, len(prices))
13882
if prices[i] - prices[i-1] > 0]
13983
return sum(gains)
140-
print(Solution().maxProfit([7, 1, 5, 3, 6, 4]))
14184
#评论区里都讲这是一道开玩笑的送分题.
14285
```
14386

0 commit comments

Comments
 (0)