Doubt in HISTOGRAM

can u tell me the approach or a hint to solve this question?

@harsh.hj
Read the following article. It has explained this approach:

  1. push(): jab current bar ki value previous bar ki value se larger ho then push in the stack,
    WHY!!
    Reason:
    the new bar can also contribute in the rectangle formed by the previous bar.
  2. pop(): agar current bar ki value previous bar ki value se smaller hai then pop from the stack,
    WHY!!
    Reason:
    The new bar would not contribute in the rectangle formed by the previous bar. Thus, we will keep popping the bars until the height of bar at stack top is not smaller or equal to the new bar.

Hope, this would help.