Why did I get Time Limit Exceeded for no input?

  • 0

    I has specified the corner cases in my code:

    def largestRectangleArea(self, height):
        if len(height) == 0 or not height:
            return 0
        if len(height) == 1:
            return height[0]
            min_val, min_index = min((val, idx) for (idx, val) in enumerate(height))
            left_max = self.largestRectangleArea(height[:min_index])
            right_max = self.largestRectangleArea((height[min_index+1:]))
            this_max = min_val*len(height)
        return max(left_max, right_max, this_max)

    However, I got TLE for:

    Last executed input: [ ]

    Any idea how may this happen? Many hanks!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.