CTCI 9.5 get all permutations of a string