This post is completed by 5 users

  • 0
Add to List

58. Generate All String Permutations

Objective: Given a String, print all the permutations of it.


Input : abc
Output: abc acb bac bca cba cab


  1. Take one character at a time and fix it at the first position. (use swap to put every character at the first position)
  2. make recursive call to rest of the characters.
  3. use swap to revert the string back to its original form fo next iteration.

abc acb bac bca cba cab