I have recheck the solution and the logic seems to be correct


but still the program isnt working, can you help me figure out why?

Hi
refer this https://ide.codingblocks.com/s/616245

Can you please tell me what was wrong in my code? I cannot figure that out

while(prices[i]>=prices[idx.top()] && !idx.empty()){
over here check the condition of !idx.empty() first and then the other condition…
secondly u are running a loop till <n-1 make it < n
thirdly here int span[1000]={0}; u are fixing the size to 1000 while 1 <= N <= 10^6
hope it clears all ur doubts…

hi… is ur doubt cleared now??

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.