Amazon interview question

Implement C++'s next_permutation