Histogram area question


My code is giving correct output but not passing even 1 test case kindly tell mistake.

Please reply someone.

your implementation is not correct and also not optimised as well
if you are finding next and prev element then why you are using stack just use a loop

Sir i used stack to find previous smaller element and nexts smaller element for each element of the input array . The vector prev has all the indices of previous smaller elements for each element of input array and the vector next has all indices of next smaller elements of input array.

yes but that you can find using only one loop without stack

i have share some resources with you as well
you can check that also

if still you have some doubt feel free to ask

Yes sir i will watch them , but i think 2 for loops will be used to find next and previous smaller elements if we dont use a stack .

join this meet

rejoin now and before joining test your mic

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.