your sorting method is incorrect
here is my code with the coding part same just i changed the sorting method . and got AC
what @acodebreaker is correct…
I would like to give you a hint for sorting problems
If you are using C as language for coding then you may use inbuilt function named qsort() to sort the array.
You may read about it here
And if you are using C++ then using STL you may use inbuild function sort() to sort the array or vector by including algorithm header file.
You may read about sort() here.
Here is your AC code where i have replaced merge_sort() with qsort() inbuild function.