Showing Runtime error please check the code - for histogram

Yogesh, the approach you are trying to use in the code is not correct… Pls use the approach as :
long long int histogram(long long int a[], long long int n)
{
stack s;
long long int maxarea = 0;
long long int i = 0;
while(i < n)
{
if(s.empty() || a[i] >= a[s.top()])
{
s.push(i++);
}
else
{
long long int height = s.top();
s.pop();
long long int area = a[height] * (s.empty() ? i : (i-s.top()-1));
if(maxarea < area)
{
maxarea = area;
}
}
}
while(!s.empty())
{
long long int height = s.top();
s.pop();
long long int area = a[height] * (s.empty() ? i : (i-s.top()-1));
if(maxarea < area) {
maxarea = area;
}
}
return maxarea;
}