get all permutations of a given number code example
Example 1: all permutations python
import itertools
print(list(itertools.permutations([1,2,3])))
Example 2: find all permutations of a string
void permute(string a, int l, int r)
{
// Base case
if (l == r)
cout<<a<<endl;
else
{
// Permutations made
for (int i = l; i <= r; i++)
{
// Swapping done
swap(a[l], a[i]);
// Recursion called
permute(a, l+1, r);
//backtrack
swap(a[l], a[i]);
}
}
}