Solution for PermutationStep problem