how can we apprach this problem?
Move all x to end
Method -1 (time optimize)
try to use recursion
in forward tracking (while going to end)
count the no of x and maintain a string
in backtracking (while coming back)
append all x at end
Method-2
Space Optimize
while going forward if you encounter x then move it to end (don’t swap)
Reference Code
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.