next_permutation : find next lexicographically greater permutation - Tutorial
Blog
Discussion