代码如下: class Solution: def maxArea(self, height: List[int]) -> int: for i in range(nums(height)): for j in range(nums(height)): Area.append((j-i)*min(height[j],height[i])) return max(Area)
报错如下: 编译出错 Line 6: SyntaxError: invalid character in identifier
来自商科的分析,每次增加或者减少的边际效用的毛病,先尝试暴力法解题吧,小规模的计算一般没啥问题,希望以后再参加训练营的时候可以注意。 class Solution: def maxArea(self, height: List[int]) -> int: Area = 0 for i in range(len(height)): for j in range(i,len(height)): Area=max(Area,(j-i)*min(height[j],height[i])) return Area