Largest area under histogram


wrong ans

  1. define a stack and push the first element’s index into it
  2. if the current element is less than the element at top, pop until the stack is empty or the current element >= top
  3. while popping calculate maxarea = max(maxarea, (i-top)*arr[top])
  4. push this element
  5. at the end, until the stack is empty use the same formula for maxarea again

The code that you provided was empty