Aristocrat interview question

Card shuffling logic in best complexity.