Sep 28, 2017

Next Permutation is the immediate lexicographically larger permutation of a sequence.

In most languages there is a function already implemented.

In C++
string s("abcd"); 
will give
Note that when a string is already the lexicographic largest, next_permutation returns 0 and hence doesn't loop forever if given in a while loop.

Post a Comment

Featured Post

Trading volumes of most major cryptocurrencies across leading exchanges remain low overall

Bitcoin's daily trading volume has been relatively low