Pergunta de entrevista da empresa eBay

finding all permutations of a string with minimum complexity