Why my this code not submitted it gives write answer then which test cases fails

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

int main()
{

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

for(int i=0;i<n-1;i++)
{
for(int j=n-1;j>i;j–)
{
if(a[i]>a[j])
{
swap(a[i],a[j]);
c++;
}
}
}
cout<<c;

}

hi @tarunkumar08yadav your logic is wrong
refer https://www.youtube.com/watch?v=m-8_yQao-lI&t=62s

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.