#include<bits/stdc++.h>
using namespace std;
//FIRST REPEATING ELEMENT (APPROACH 2)
int main()
{
    cout<<"running";
    int n;
    cin>>n;
    int arr[n];
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    const int N = 1e5+2;
    int idx[N];
    for(int i=0;i<N;i++)
        idx[i] = -1;
    int minidx = INT_MAX;
    for(int i=0;i<n;i++)
    {
        if(idx[arr[i]] != -1)
            minidx = min(minidx, idx[arr[i]]);
        else
            idx[arr[i]] = i;
    }
    if(minidx == INT_MAX)
        cout<<"-1"<<endl;
    else
        cout<<minidx + 1<<endl;
    return 0;
}
I am writing this code for "First Repeating Element" question and trying to get the index of the first element that repeats. On debugging, I am getting segmentation fault. int main() { (in this line)
What does it mean and what can I do to remove this.
 
     
     
    