What's wrong with the code? It's showing TLE for all the testcases and also Pls explain the approach you have used to figure out the errors . Its giving correct output in sample test case
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.
Still it’s showing TLE … I have included #define long long int for the above code to convert all ints to long long type
ur merge funtion had error
at the end u were doing for(i=0:k)
but here a[s] to a[e] has to be replaced not a[0] to a[k]
I dont understand what is wrong with my code …But it is giving correct output for san=mple code
Okay, see in ur merge function
U made a temp array, in that temp array you have stored
temp[0…e] as sorted from a[s…e]
but for(int i=0;i<k;i++){
a[i]=temp[i];
}
here u modify a[0…k] as temp[0…k]
but s and e could have been a middle array or an array in the later half so you are modifying the values wrongly