Runtime error............unable to find

problem https://hack.codingblocks.com/contests/c/253/395
code
https://ide.codingblocks.com/s/52620

you are using while loop in mergeSort. //REASON

TO GET RID OF RUNTIME ERROR, you can use this code . Now try to find the error on your own or learn merge sort online

void mergeSort(ll *arr,ll s,ll e)
{ cout<<s<<" “<<e<<”\n";
if(s>=e)
return ;

ll mid=floor((s+e)/2);
mergeSort(arr,s,mid);
mergeSort(arr,mid+1,e);
merge(arr,s,e,mid);

}

i think it should be if(s<=e)

https://ide.codingblocks.com/s/52827
I have updated the code but it is still giving runtime error

size of array is (2 )* 10^6 and you are making array of only 10^6.
Just make array more than 2*10^6 i.e. your code will pass.
Hit like if u get it

1 Like

thank you…

Hit like bhai … :stuck_out_tongue:

1 Like