Backtracking Is Not Use Why?

why we don’t need to backtrack here I m not able to get,becoz without we won’t be able to get all permutation of string. what if we miss some of the cases.

Hello @vikram.keswani108,

  1. The order in which the question demand the output or strings to be printed is not exactly how dictionary stores word.
  2. Its solution is not possible using backtracking.
    If you’ll use backtracking then the output that your code would produce would be different than the required one(in terms of order).
  3. if you’ll do the second swap then you backtrack to original position before the next swap but in the same function call.
  4. Without backtracking, changes persist within the called function for each swap but do not reflects back in the calling function.

To understand this better write both recursive and backtracking code and print the string.

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

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.