It is giving correct answer for all sample cases

why is it showing runtime error here

#include
using namespace std;

void merge(int arr[],int s,int m,int e){
int i=s;
int j=m+1;
int k=s;
int temp[100000];
while(i<=m &&j<=e){
if(arr[i]<arr[j]){
temp[k++] = arr[i++];

	}
	else{
		temp[k++] = arr[j++];
	}
}
if(i<=m){
	while(i<=m){
		temp[k++] = arr[i++];
	}
}
if(j<=e){
	while(j<=e){
		temp[k++] = arr[j++];
	}
}
for(int b = s;b<=e;b++){
	arr[b] = temp[b];
}
return;

}

void merge_sort(int arr[],int s,int e){
//base case
if(s>=e){
return;
}

int m =(s+e)/2;
merge_sort(arr,s,m);
merge_sort(arr,m+1,e);
merge(arr,s,m,e);

}

int main() {
int len;
cin>>len;
int arr[100000];
for(int i=0;i<len;i++){
cin>>arr[i];
}
merge_sort(arr,0,len-1);
for(int i=0;i<len;i++){
cout<<arr[i]<<" ";
}
return 0;
}

Hey @saurabh66
Please share your code in Coding Blocks IDE

Hey @saurabh66
Updated ur code and mentioned the changes in comments : https://ide.codingblocks.com/s/354169 :slight_smile:
If this resolves ur query then please mark it as resolved :slight_smile:

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.