Courses

Apple Coding Interview

Apple's staples: intervals, an LRU cache, prefix sums, and rebuilding trees from traversals.

Islands
8
Lessons
72
Exercises
249
Complete codeDebugCode orderMultiple choiceTapTrace
  1. Island 1

    Reverse Linked List

    Turn a singly linked list around so every arrow points the other way.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  2. Island 2

    Best Time to Buy and Sell Stock

    Pick one day to buy and a later day to sell for the biggest possible profit.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  3. Island 3

    Merge Intervals

    Collapse a list of possibly-overlapping intervals into the fewest non-overlapping ones.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  4. Island 4

    Total Hamming Distance

    Sum the bit-differences over every pair of numbers in the array — without checking every pair.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  5. Island 5

    Subarray Sum Equals K

    Count how many contiguous stretches of an array sum to exactly k.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  6. Island 6

    Course Schedule II

    Produce an actual order to take every course given its prerequisites — or report that none exists.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze4 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  7. Island 7

    Construct Binary Tree from Preorder and Postorder Traversal

    Rebuild a binary tree knowing only the order its nodes were visited — twice, differently.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
  8. Island 8

    LRU Cache

    Design a fixed-size cache where get and put run in constant time and the least recently used entry is evicted first.

    1. Decode the Problem3 exercises, 4 min
    2. Approach Check4 exercises, 4 min
    3. Build the Brute Force3 exercises, 5 min
    4. Find the Bottleneck2 exercises, 4 min
    5. Discover the Optimal Approach3 exercises, 4 min
    6. Assemble the Algorithm2 exercises, 5 min
    7. Read the Implementation3 exercises, 5 min
    8. Test and Analyze3 exercises, 4 min
    9. Boss BattleBoss8 exercises, 8 min
AlgoFox Pro

Apple Coding Interview is part of AlgoFox Pro

You can read the whole course outline here. The exercises are in the app, along with your streak, your mistake review, and the progress that carries across your devices.

Pro starts with a 3 day free trial. The app store decides who is eligible for an introductory offer, and a lapsed subscription does not get another one.

Download AlgoFox on the App StoreGet AlgoFox on Google Play

Already subscribed in the app? Sign in with the same account and Pro works here too. Quick Play and Battle are free on the web, and so is the first course in every subject.