The algorithm which I know is the below but why I hate this approach is it's time complexity is O((n+1)!) too worse in case of large strings
Start by sorting the string and printing that as the first permutation.
Now, we can find the next permutation as follows:Let i be the last index such that input[i] < input[i + 1]. If there is no such index, then we’re done. Let j be the last index such that input[i] < input[j]. Swap input[i] with input[j]. Reverse input[i + 1] through input[input.length - 1].
Is there any better approach than the above one ?(If explanation is through code then please consider c or c++)... just I am expecting a better algorithm with lesser time complexity than the above one