Pregunta de entrevista de eBay

finding all permutations of a string with minimum complexity