Why code is not working(working for sample test case)

to find max area of histogram