Permutation Operations Hackerrank Solution