What is the time complexity of the code shown in the tutorial video of the permutation of strings (done by swapping the chars of the strings)?
Isn’t it O(N*N)?
CPP Permutations
Time Complexity: O(n*n!)
because there are n! permutations and it requires O(n) time to print a a permutation.
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask
can we reduce the time complexity?
i think no
because no of permutations are n! it will remain same
and size of each permutation will also n
so no scope of reducing time complexity