How does the shifting works behind the scenes?

This part of the code went over.

while ( j >= i + 1 ) {
a [ j + 2 ] = a [ j ];
j–;
}

hello @udatta

let say we have string .
abc
and we want to create two empty space in front i,e
we want something as
- - a b c

so what we need to do
abc- - move c 2 place to right
ab- - c
now move b 2 place to right
a- - bc
now move a 2 place to right
- - a b c
we get this

Okay so j-- is actually going back and shifting b and then a respectively to right. Right?

yeah…

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.