Stock Span Problem

ans - https://ide.codingblocks.com/s/229746
it is not giving the correct Output.This problem is from class tut.

hi @sudhanshu8917

in line no 13
instead of if condition use while loop because we have to remove all values from stack whose value is less than current day price

so correct one is
while( (s.empty()==false) && a[s.top()]<curPrice){
s.pop();
}