I am getting error in this, please help me debug
Histogram Stack Problem
It worked. This seems like a conceptual error, can you explain how both aren’t the same?
I am still failing all test cases. Please help
@Tapan
there is difference between (!s.empty() && arr[s.top()] > x ) and ( arr[s.top()] > x && !s.empty())
see program execute every statement from left to right. So in first case, first !s.empty() execute if it is false, whole condition become false and our program don’t check second condition i.e arr[s.top()]>x.
But in second case, first arr[s.stop()] execute which gave segmentation fault if our s queue is empty(i.e we don’t have s.top() )