PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Apple

Design a deck of cards with shuffle/draw

Last updated: Jun 2, 2026

Quick Overview

This question evaluates object-oriented design skills, understanding of randomness and probability in algorithms, and analysis of time/space complexity for data structures and operations.

  • medium
  • Apple
  • Software Engineering Fundamentals
  • Software Engineer

Design a deck of cards with shuffle/draw

Company: Apple

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

## Object-Oriented Design + Randomness Design an in-memory model of a standard 52-card deck. ### Requirements - Create classes to represent at least: - `Card` (rank and suit) - `Deck` (a collection of cards) - The `Deck` must support: 1. `shuffle()` — randomizes the order of the remaining cards. 2. `draw()` — removes and returns one card from the deck. ### Correctness / Probability Constraints - After calling `shuffle()`, every permutation of the remaining cards should be equally likely (i.e., an unbiased shuffle). - Each `draw()` should return each remaining card with equal probability at that moment. ### Additional Considerations - Define what should happen when `draw()` is called on an empty deck. - Discuss time/space complexity targets for `shuffle()` and `draw()`. - You may assume a good PRNG is available (e.g., `Random`).

Quick Answer: This question evaluates object-oriented design skills, understanding of randomness and probability in algorithms, and analysis of time/space complexity for data structures and operations.

Related Interview Questions

  • How to root-cause Wi‑Fi chip stops after 30 minutes - Apple (medium)
  • How to debug a Python loop-condition bug - Apple (medium)
  • Explain thermal and signal fundamentals - Apple (hard)
  • Explain key React concepts and error handling - Apple (medium)
  • Make tree iterators safe under concurrency - Apple (hard)
Apple logo
Apple
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
30
0

Object-Oriented Design + Randomness

Design an in-memory model of a standard 52-card deck.

Requirements

  • Create classes to represent at least:
    • Card (rank and suit)
    • Deck (a collection of cards)
  • The Deck must support:
    1. shuffle() — randomizes the order of the remaining cards.
    2. draw() — removes and returns one card from the deck.

Correctness / Probability Constraints

  • After calling shuffle() , every permutation of the remaining cards should be equally likely (i.e., an unbiased shuffle).
  • Each draw() should return each remaining card with equal probability at that moment.

Additional Considerations

  • Define what should happen when draw() is called on an empty deck.
  • Discuss time/space complexity targets for shuffle() and draw() .
  • You may assume a good PRNG is available (e.g., Random ).

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Apple•More Software Engineer•Apple Software Engineer•Apple Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.