Logic was to get the shuffled deck and check if the last card in shuffled deck belongs to the top of half 1 of half 2.
-do while loop until shuffled deck is empty.
-pick a card from the shuffled deck - check if it's the top card of half 1 or half2.
-if it matches top of half1 - pop it from half1, pop from deck.
-else if is top of half2, repeat.
-if the card does not match the top of either halves, it's not a single shuffle.
I think I could improve this. I am not sure yet what the complexity of using pop is.
If its always O then this logic is good. But anyhow since the max deck of cards is always 52, change in performance wont make much difference even with better code than this.
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.