can anyone please tell me that

What is Time complexity for finding all permutations of a number?

What is Time complexity for finding all permutations of a string?

can anyone please tell me that

What is Time complexity for finding all permutations of a number?

What is Time complexity for finding all permutations of a string?

The time complexity for finding all permutations of a string of length n is O(n!). Similarly for a number, n = *number of digits in number*.

finding all permuations and printing them takes O(n! * n) time.

Am I correct or wrong?

its just n! i guess use next_permutation in C++

1 Like

If you just want to find all permutation of a string , then it can be done in O(n!) . But if you also want to print/traverse that permutation , it can be done in O(n!*n) because printing/traversing would require O(n) time.