Booking.com interview question

The coding question was a simple permutation related problem, can be solved using recursion.