One testcase of leetcode is not working but in this all test case are working and i got 100 this is the testcase 3 [1,2,1] 2

#include
#include<unordered_map>
using namespace std;
int main() {
int n;
cin>>n;
unordered_map<int,int> h;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
h[arr[i]]++;
}
int k;
cin>>k;
int ans=0;
for(int i=0;i<n;i++)
{
if(h[arr[i]]>1)
{
for(int j=i+1;j<n;j++)
{
if(arr[i]==arr[j] && abs(i-j)<=k){
ans=1;
break;
}else{
j++;
}
}

    }
}
if(ans==0){
    cout<<"false";
}else{
    cout<<"true";
}
return 0;

}

hey @diamond_saroha ,
I guess in the leetcode question the absolute difference should be less than k .
If you can provide me with the question link of leetcode i will be able to assist you better

And send your solution in a ide link so that it is easier to debug