def demo(nums): dp=[nums[0]] for i in nums[1:]: dp.append(max(i,dp[-1]+i)) return max(dp) print(demo([-2,1,-3,4,-1,2,1,-5,4]))
2024-01-21 09:18:04
def demo(nums): dp=[nums[0]] for i in nums[1:]: dp.append(max(i,dp[-1]+i)) return max(dp) print(demo([-2,1,-3,4,-1,2,1,-5,4]))
下一篇:oepn sync