Apple·Software Engineer·Technical Phone Screen
- Design a playing-card deck library with two methods: shuffle(), which returns a uniformly random permutation of a standard 52-card deck, and order(), which returns the cards sorted by rank then suit (using the ordering Clubs, Diamonds, Hearts, Spades within each rank, starting from 3 up through Ace). Define your data structures, explain how you guarantee an unbiased shuffle, and analyze time and space complexity.
“I started with the data structure and defined a Card as a pair of rank and suit enums, deck as a fixed array of 52.”