cool algorithm to find Next Permutation