Question d’entretien chez Meta

Asked the next permutation problem.