Aristocrat Interview Question

Card shuffling logic in best complexity.