eBay Interview Question

finding all permutations of a string with minimum complexity