I was working on a problem statement related to permutations of a given string when I came across this question of its time complexity. Working up a solution myself I got O(n!), Which in turn is incorrect according to the “Cracking the Coding Interview” which was referenced in one of the geeks for geeks posts. It claimed the complexity to O(n² * n!), Where n is the length of the string. To verify the result I sought answers in forums (StackOverflow, wiki, etc.), Even here people were not sure about either of the two.

Image

Continue reading at medium