**I'm using minGW(6.3.0) compiler on my windows 10, I was practicing for ds&algo but my c++ code compiled successfully but didn't run, I then tried it on online compiler like(onlinegdb.com) there it worked properly, can you help figure out what is happening **
btw, this program is first_repeating_arr to find first lowest first repeating array input: size(7), arr(1 5 3 4 3 5 6), output: 2
#include "bits/stdc++.h"
using namespace std;
int main ()
{
int n;
cin >> n;
int ar[n];
for (int i = 0; i < n; i++)
{
cin >> ar[i];
}
// pre-defining array for large constraints.(as we see in online competition)
const int N = 1e6 + 2;
int idx[N];
for (int i = 0; i < N; i++)
{
idx[i] = -1;
}
int minid = INT_MAX;
for (int i = 0; i < n; i++)
{
if (idx[ar[i]] != -1)
{
minid = min (minid, idx[ar[i]]);
}
else
{
idx[ar[i]] = i;
}
}
if (minid == INT_MAX)
{
cout << "-1" << endl;
}
else
{
cout << minid + 1 << endl;
}
return 0;
}