Skip to main content

Apple Coding Interview Questions

32 Apple coding interview problems with full optimal solutions — 11 easy, 19 medium, 2 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Apple interviewer values, and a FAQ section.

  • #21easyfoundational

    21. Two Sum

    Find two indices whose values sum to a target — Apple uses this warmup to see if you reach for the right data structure immediately, reflecting the precision-first engineering culture behind Core Data's element-lookup caches.

  • #22easyfoundational

    22. Valid Parentheses

    Determine if bracket sequences are properly closed and ordered — Apple's Xcode editor and Swift compiler use this classic stack pattern daily to validate nested UI element trees, undo-stack integrity, and balanced XML attribute scopes in Interface Builder.

  • #23easyfoundational

    23. Climbing Stairs

    Count distinct ways to reach step n taking 1 or 2 steps at a time — Apple uses this DP gateway problem to test whether you recognize Fibonacci recurrences, a pattern behind animation frame interpolation in Core Animation.

  • #24easyfoundational

    24. Binary Search

    Search a sorted array in O(log n) — Apple tests binary search as a stand-alone problem because getting the boundary conditions exactly right mirrors the precision required when indexing sorted Core Data fetch results or bisecting version ranges in Software Update.

  • #25mediumfoundational

    25. Find Minimum in Rotated Sorted Array

    Find the minimum element in a rotated sorted array in O(log n) — Apple asks this to test whether you can adapt binary search when invariants are partially broken, a skill directly applicable to finding pivot points in macOS system log timestamps.

  • #26mediumfoundational

    26. Number of Islands

    Count connected land regions in a binary grid using BFS/DFS — Apple applies this grid-traversal pattern to UI layout engines that must identify distinct content regions on a display, and to Maps clustering connected geographic tiles.

  • #27mediumfoundational

    27. Course Schedule

    Detect circular dependencies in a directed graph — Apple's Xcode build system and Swift Package Manager use topological sort to resolve framework dependency graphs; cycle detection is the first thing that must work correctly before any build starts.

  • #28mediumfoundational

    28. Validate Binary Search Tree

    Verify that every node in a binary tree satisfies the full BST invariant — Apple's file system and UI accessibility tree code depends on validated sorted structures, making this a core screening question for roles touching CoreData or UIAccessibility.

  • #29mediumfoundational

    29. Decode Ways

    Count all valid decodings of a digit string where 1-26 map to A-Z — Apple uses this DP pattern to evaluate how engineers reason about combinatorial text-parsing states, directly analogous to the multi-codepoint emoji rendering decisions in iMessage.

  • #30mediumfoundational

    30. Rotate Image

    Rotate an n×n matrix 90 degrees clockwise in-place — Apple's AVFoundation and Photos frameworks rotate CVPixelBuffer image data without allocating extra memory on memory-constrained iPhones, making this in-place matrix transformation a consistent favorite for Camera and Vision team interviews.

  • #31mediumfoundational

    31. Kth Largest Element in an Array

    Find the kth largest element without full sorting — Apple Fitness+ and HealthKit stream millions of events and must surface top-k rankings in real time; this heap/quickselect problem is a direct analog of that competitive-leaderboard challenge.

  • #32hardfoundational

    32. Serialize and Deserialize Binary Tree

    Convert a binary tree to a string and back — Apple's UIKit view hierarchy and iCloud backup systems both serialize arbitrary tree structures to transmit state across devices; this hard problem tests whether you can design a stable, lossless encoding for hierarchical data.

  • #2mediumfrequently asked

    2. Add Two Numbers

    Add Two Numbers is Apple's linked-list-as-digits arithmetic question. Walk both lists in parallel, adding digit + digit + carry, allocate a new node per output digit, and handle different lengths and a possible trailing carry. The dummy-head trick keeps the code tidy.

    4 free resourcesSolve →
  • #3mediumfoundational

    3. Longest Substring Without Repeating Characters

    Longest Substring Without Repeating Characters is the canonical sliding-window question and Apple's most-repeated string medium. Expand the right pointer; when a duplicate appears, jump the left pointer to last_index_of_dup + 1. The hash-map-of-char-to-last-index variant is what Apple grades on.

    4 free resourcesSolve →
  • #7mediumfrequently asked

    7. Reverse Integer

    Reverse Integer is Apple's deceptively-simple overflow-detection question. The reversal loop is three lines; the real challenge is detecting 32-bit overflow BEFORE it happens. Apple grades on whether you remember -2^31 to 2^31 - 1 and check the bound on every digit append.

    4 free resourcesSolve →
  • #8mediumfrequently asked

    8. String to Integer (atoi)

    String to Integer (atoi) is Apple's adversarial parsing question. Six precise rules — skip whitespace, read optional sign, read digits, clamp to 32-bit — and you must handle every weird input the interviewer throws at you. Apple grades on edge-case coverage, not on the parse loop itself.

    4 free resourcesSolve →
  • #14easyfoundational

    14. Longest Common Prefix

    Longest Common Prefix is Apple's clean string-array warm-up. The vertical-scan answer (compare position 0 across all strings, then position 1, ...) beats the horizontal scan in average case and is what Apple grades on. Mention the trie variant if asked for a more reusable structure.

    4 free resourcesSolve →
  • #15mediumfrequently asked

    15. 3Sum

    3Sum is Apple's introduction to fix-one-then-two-pointer pattern. Sort the array, fix nums[i] as the anchor, then run a two-pointer sweep for the other two values that sum to -nums[i]. The duplicate-skipping is the bug surface Apple specifically grades on.

    4 free resourcesSolve →
  • #21easyfoundational

    21. Merge Two Sorted Lists

    Merge Two Sorted Lists is Apple's canonical linked-list warm-up. The dummy-node trick — start with a dummy then thread the smaller of the two heads onto its tail — keeps the code clean and edge-case-free. Apple grades on whether you reach for the dummy unprompted.

    4 free resourcesSolve →
  • #102mediumfrequently asked

    102. Binary Tree Level Order Traversal

    Binary Tree Level Order Traversal is Apple's canonical BFS-on-a-tree question. Process the queue one level at a time by snapshotting its size at the start of each iteration. Apple grades on whether you remember the size snapshot — most candidates accidentally bleed levels together.

    4 free resourcesSolve →
  • #104easyfoundational

    104. Maximum Depth of Binary Tree

    Maximum Depth of Binary Tree is Apple's pure recursion warm-up. depth(node) = 1 + max(depth(left), depth(right)) with base case 0 on null. The interviewer wants you to also know the iterative BFS variant for environments where recursion depth is a concern.

    4 free resourcesSolve →
  • #121easyfoundational

    121. Best Time to Buy and Sell Stock

    Best Time to Buy and Sell Stock is Apple's canonical single-pass max-tracking question. The trick is recognizing this as 'maximum running-difference' — you only need the minimum-so-far and the best diff. The O(n^2) brute force is mentioned and rejected; the linear scan is the answer.

    4 free resourcesSolve →
  • #127hardfrequently asked

    127. Word Ladder

    Word Ladder is Apple's BFS-on-a-virtual-graph hard. The trick is generating neighbors implicitly — for each word, try replacing each letter with each of 26 alternatives. BFS guarantees the shortest path. Bidirectional BFS is the optimization for the 'now make it faster' follow-up.

    4 free resourcesSolve →
  • #146mediumfrequently asked

    146. LRU Cache

    LRU Cache is Apple's flagship data-structure design medium. The answer is a hash map for O(1) lookup plus a doubly linked list for O(1) move-to-front. Apple specifically grades on whether you handle the pointer surgery without leaving a dangling neighbor.

    4 free resourcesSolve →
  • #198mediumfrequently asked

    198. House Robber

    House Robber is Apple's clean 1D DP medium. dp[i] = max(dp[i-1], dp[i-2] + nums[i]) — either skip this house or take it plus the best up to two back. Apple grades on whether you can derive that recurrence on the spot and reduce to O(1) space.

    4 free resourcesSolve →
  • #211mediumfrequently asked

    211. Design Add and Search Words Data Structure

    Design Add and Search Words Data Structure is Apple's go-to trie design medium. Add inserts a word normally; search supports '.' as a wildcard that matches any single character. The wildcard turns the search into a tiny DFS down every matching child node.

    4 free resourcesSolve →
  • #225easyfrequently asked

    225. Implement Stack using Queues

    Implement Stack using Queues is Apple's mirror to Queue-using-Stacks. The clever variant is one queue with rotate-on-push: after pushing x, dequeue and re-enqueue every existing element so x ends up at the front. Push becomes O(n); pop/top become O(1).

    4 free resourcesSolve →
  • #232easyfrequently asked

    232. Implement Queue using Stacks

    Implement Queue using Stacks is Apple's classic 'reverse the access pattern' design easy. Two stacks — one for input, one for output. The trick is the amortized O(1) pop: only move from input to output when output is empty, so each element moves at most once.

    4 free resourcesSolve →
  • #236mediumfrequently asked

    236. Lowest Common Ancestor of a Binary Tree

    Lowest Common Ancestor is Apple's elegant tree recursion medium. The clean answer is dual: 'return p or q if found, else return whichever subtree returned non-null — if both subtrees return non-null, this node is the LCA.' Five lines that make Apple interviewers smile.

    4 free resourcesSolve →
  • #238mediumfrequently asked

    238. Product of Array Except Self

    Product of Array Except Self is Apple's beloved 'no division' question. Two passes — left-products then right-products into the same output array — gives O(n) time with O(1) extra space. Apple grades on whether you avoid division entirely and handle the multi-zero case.

    4 free resourcesSolve →
  • #242easyfoundational

    242. Valid Anagram

    Valid Anagram is the Apple warm-up that grades whether you pick the right approach for the constraint. Sort-both is the lazy answer; frequency-count is the optimal. The Unicode follow-up is what Apple uses to separate easy passes from strong easy passes.

    4 free resourcesSolve →
  • #322mediumfrequently asked

    322. Coin Change

    Coin Change is Apple's go-to unbounded-knapsack DP medium. dp[i] = min coins to make amount i. For each i, try every coin and take the minimum. Apple is grading whether you can write the recurrence AND explain why the greedy (take the largest coin) does not work on arbitrary denominations.

    4 free resourcesSolve →

Related interview-prep guides

Interview Platforms

HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds

HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.

Interview Platforms

LeetCode Assessments: The 2026 Tech Interview Guide

LeetCode Assessments is the enterprise tier of the LeetCode platform: a separate product from the public site candidates know from grinding problems. Companies pay LeetCode to build custom timed assessments that draw from the 3,000-problem public catalog plus optional private variations, and the catalog asymmetry is the whole story for prep.

Interview Platforms

Zoom Tech Interview Guide 2026: How the Platform Works for Engineering Hiring

Zoom is the most-deployed video meeting software in US tech hiring. It is the default from one-person startups to Fortune 100 engineering orgs. It is general-purpose meeting software, not an anti-cheating platform. This guide covers what Zoom sees during a tech interview, the screen-share modes hiring teams use, the OS-level boundary the platform cannot cross, and how a modern desktop interview assistant pairs with the standard Zoom tech-interview flow.

Apple Coding Interview Questions — Full Solutions — InterviewChamp.AI