剑指offer python版 股票最大收益
def aa(nums): a,b=0,1 ret=[] leng=len(nums) for i in range(leng-1): for j in range(i+1,leng): ret.append(nums[j]-nums[i]) return max(ret) print(aa([9,11,8,5,7,12,16,14]))
def aa(nums): a,b=0,1 ret=[] leng=len(nums) for i in range(leng-1): for j in range(i+1,leng): ret.append(nums[j]-nums[i]) return max(ret) print(aa([9,11,8,5,7,12,16,14]))