Dec-02-2020, 11:47 PM
(Dec-02-2020, 11:40 PM)deanhystad Wrote: One other thing. This is not important for this challenge because your solution will not have loops inside loops, but there is a better way to do the looping you were doing in your OP.It's better but still time out.
class Solution: def maxArea(self, height): result = 0 for i in range(len(height)-1): for j in range(i+1, len(height)): result = max(result, min(height[i], height[j]) * (j - i)) return resultThis shaves about 10 seconds off your code. This makes sense because the iterations are cut in half.