Microsoft interview question

implement permutation function without using libraries