Test case 0 does not pass while all other passs

using namespace std;

class Solution{
public:
vector nextLargerElement(vector arr, int n){
vector ans;
stack s;
for(int i=n-1;i>=0;i–)
{
while(s.size()>0&&arr[i]>=s.top())
s.pop();

        if(s.size()==0)
        ans.push_back(-1);
        else
        ans.push_back(s.top());
        
        
        s.push(arr[i]);
    }
    
    reverse(ans.begin(),ans.end());
    
    return ans;
}

};

int main()
{
int t;
t=1;
while(t–)
{

    int n;
    cin>>n;
    vector<long long> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    Solution obj;
    vector <long long> res = obj.nextLargerElement(arr, n);
    for (long long i : res) cout << i << " ";
    cout<<endl;
}
return 0;

}

pls save ur code on ide(https://ide.codingblocks.com/) and send link
or u can refer this https://ide.codingblocks.com/s/581542

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.