educative.io

https://www.educative.io/courses/grokking-the-coding-interview/xVlKmyX542P

https://www.educative.io/courses/grokking-the-coding-interview/xVlKmyX542P

Mistake on Time and Space complexity? Looks like these permutations are 2N instead of 2^N. So Time Complexity would be O(N2N) and Space Complexity O(2N) isn’t it? If the input is ab7c our outpull will contains 24 (being N the size of the string)

Every time we change the character’s case we multiply current space size by two. And the worst case would be string consisting only of letters giving the time/space complexity are O(N* 2^N).