Maximum rectange of 1s doubt

Here’s my code to this problem and its working but the part where we need to find the maximum area under the histogram is way too long. Could you suggest a better, optimized approach?

hello @nidhigupta847
yeah instead of doing preprocessing for left and right array , u can use single stack to get max area historgram.
here is the approach->link

But I can’t understand the approach used on gfg. Any video reference ?

@nidhigupta847