Getting segmentation fault for the code on gfg

i was solving merge sort question on gfg. it is complied but when i am trying to submit code it is giving segmentation fault.

void merge(int *arr, int s, int m, int e)
{
// Your code here
if(e==s) return;

     int i=s,j=m+1,k=0;
     int temp[e-s+1];
     while(i<=m && j<=e)
     {
         if(arr[i]<arr[j])
         {
             temp[k++]=arr[i++];
         }
         else
         {
             temp[k++]=arr[j++];
         }
     }
     while(i<=m)
     {
         temp[k++]=arr[i++];
     }
     while(j<=e)
     {
         temp[k++]=arr[i++];
     }
     for(i=s;i<=e;i++)
     {
         arr[i]=temp[i-s];
     }
}
public:
void mergeSort(int arr[], int s, int e)
{
    //code here
    if(s>=e) return;
    
    if(s<e)
    {    int m=(s+e)/2;
        mergeSort(arr,s,m);
        mergeSort(arr,m+1,e);
        merge(arr,s,m,e);
    }
}

entire code is written above .please help

hi @kratikajain2001_f5f0e90a00834752 u wrote arr[i++] in while(j<=e) loop instead of arr[j++]

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.