CPP-Permutation

In this video we have used backtracking, like we have swapped again, but what if we take another array like OUTPUT array, then will there be any need of any backtracking ?

hey pranshu, no it you are using this swapping approach than backtracking is only way. if you use output array than also you need to swap.

It can be done without backtracking but in case you have to use string.
I am sharing you an code for same. Although it is in java but it is too similar to C++ snippet.

But I will recommend you to use backtracking beacuse it very important approach and it is giving best complexity for this question.