iske alawa koi approach hai is question ko solve krne ki , and this what bhaiya had explained is the algorithm for these types of problems?? and how Do we approach a new problem like this?
STACK-HISTOGRAM AREA
Most optimized way to solve this problem is by using stack only.
Yes, but they aren’t optimized as it is
Didn’t get you please elaborate.
Okay, Can we also solve this using arrays only ??
And agar koi esi nayi problem aaye , to kese approach krenge?
Yes, in that case worst time complexity will be O(N^2) cause you have to find leftmost and rightmost nearest shortest element for n elements so N^2 in that
sbse pehle brute force he socho, fr smjh ayega kha optimize kr skta hu, wha krna. Ni smjh ayye to youtube pr problem se related videos dekhlo. Ho jayega
Okay jj, thank you
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.