Runtime Error (Largest Rectangle in Histogram )


  • 0
    T

    Can anyone give me some suggestions? I got the Runtime error. Maybe I am missing something... Thanks!

    Runtime Error Message:	Line 15: ValueError: max() arg is an empty sequence
    Last executed input:	[]
    
    
    def largest_rectangle2(height):
    	area_all=[]
    	for i in range(len(height)):
    		area=[]
    		start=i
    		step=1
    		while start+step<=len(height):
    			B=height[start:start+step]
    			area.append(min(B)*step)
    			step=step+1
    		area_all.append(max(area))
    	area_max=max(area_all)
    	return area_max
    
    if __name__ == '__main__':
        height = [0,0,5,4,5,1,6]
        print largest_rectangle2(height)

  • 0
    Z

    Looks like you ran max([]).


Log in to reply
 

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