Pergunta de entrevista da empresa Morgan Stanley

finding next smallest permutation of a given number