code :https://ide.codingblocks.com/s/55434
I am getting RE . Unable to identify.
Ques link:https://hack.codingblocks.com/contests/c/471/404
Stock Span Problem- RE
How && operator works
if(condition 1 && condition 2)
here, condition 1 is checked , if it is true then it will check condition 2.
In line 28 : condition 1: a[i]>=a[s.top()] Condition 2: !s.empty()
Let say stack is empty then condition 1 will give run time error as there is no location of s.top()
So, just swap order of condition1 and 2.
make condition 1: !s.empty() and condition 2: a[i]>=s[s.top()]
You will get rid of Runtime Error. Enjoy.
Hit like if u get it