Skip to content

Commit ffdf576

Browse files
committed
Finish 121
1 parent 66692b1 commit ffdf576

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution(object):
2+
def maxProfit(self, prices):
3+
"""
4+
:type prices: List[int]
5+
:rtype: int
6+
"""
7+
sellPrice = 9999999
8+
length = len(prices)
9+
maxAns = 0
10+
for x in range(0, length):
11+
if prices[x] < sellPrice:
12+
sellPrice = prices[x]
13+
if prices[x] > sellPrice:
14+
temp = prices[x] - sellPrice
15+
if temp > maxAns:
16+
maxAns = temp
17+
return maxAns

0 commit comments

Comments
 (0)