after the loop ends array [j]= val instead of array of j+1
J or j+1 array which is correct
because we comparing the key val in the loop
so after that we have to place that at its position
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.