Test cases failed max hsitogram area

#include
#include <bits/stdc++.h>
using namespace std;

int getMaxArea(int a[],int n){
int res=0;
int tp;
int curr;
stack s;
for(int i=0; i<n ; i++){
while(s.empty()==false && a[s.top()]>=a[i]){
tp=s.top();s.pop();
curr=a[tp](s.empty()?i:i-s.top()-1);
res= max(res,curr);
}s.push(i);
}
while(s.empty()==false){
tp=s.top();s.pop();
curr=a[tp]
(s.empty()?n:n-s.top()-1);
res= max(res,curr);
}

return res;

}

int main() {

int n;
cin>>n;
int a[n];

for(int i=0;i<n;i++) cin>>a[i];

cout<<getMaxArea(a,n);
return 0;

}

Hi,
pls save ur code on ide and send or refer my code https://ide.codingblocks.com/s/623315

Hi,
u can do this way also https://ide.codingblocks.com/s/624213

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.