题解 | #牛群售价预测#
牛群售价预测
https://www.nowcoder.com/practice/bbdb8d6f3a2e434e87f749358d16d653
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param prices int整型一维数组
# @return int整型
#
import math
class Solution:
def max_profit(self , prices: List[int]) -> int:
# write code here
if len(prices) == 1:
return 0
length = len(prices)
dp = [0] * length
for i in range(1, length):
for j in range(i):
dp[i] = max(dp[i], prices[i]-prices[j])
return max(dp)
网易游戏公司福利 630人发布
