Problem in MERGESORT Question

Hello, my code is giving WA for the THIRD CASE.
Please help up with my code…
Code Link -> https://ide.codingblocks.com/s/132133

Hello @saurabhpandey59373,

The problem is the parameters that you are passing in the mergeSort () function:
Solution:
mergeSort (arr, 0, n-1);
Reason:
If you would dry run your code, you would find that it is taking wrong values of n1 and n2.
for the very first case:
mid=2, lo=0, hi=5
n1=3, n2=3 (which means 6 elements)
But, there are only 5 elements in the array.

Hope, this would help.
Give a like, if you are satisfied.

Oki thanx sir. I got it right now. :slight_smile:

Great.:blush:

Please, mark this doubt as resolved if you have no more questions regarding this thread.