Skip to content

Apple Coding Questions 2025 - Interview Problems with Solutions

Apple coding interview questions with detailed solutions in Python, Java, and C++. Practice DSA problems asked in Apple SWE interviews 2025.

Apple Coding Questions - Complete Problem Set

Section titled “Apple Coding Questions - Complete Problem Set”

Practice 25+ Apple coding interview questions with solutions in multiple languages. Apple focuses on clean code, optimal solutions, and edge case handling.

Find indices of two numbers that add up to target.

Input: nums = [2,7,11,15], target = 9
Output: [0,1]

Find two lines that form container with most water.

Input: [1,8,6,2,5,4,8,3,7]
Output: 49

3. Longest Substring Without Repeating Characters

Section titled “3. Longest Substring Without Repeating Characters”

Find length of longest substring without repeating characters.

Input: “abcabcbb”
Output: 3 (“abc”)

Return array where each element is product of all other elements.

Input: [1,2,3,4]
Output: [24,12,8,6]

Calculate water trapped after raining.

Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6

Check if binary tree is a valid BST.

Find maximum path sum in binary tree. Path can start and end at any node.

Input: [-10,9,20,null,null,15,7]
Output: 42 (15 + 20 + 7)

Count number of islands in 2D grid.

Find LCA of two nodes in binary tree.

Check if all courses can be finished given prerequisites.

Find length of longest increasing subsequence.

Input: [10,9,2,5,3,7,101,18]
Output: 4

Find minimum coins needed to make amount.

Input: coins = [1,2,5], amount = 11
Output: 3 (5+5+1)

Can string be segmented into dictionary words?

Input: s = “leetcode”, wordDict = [“leet”,“code”]
Output: true

Max money without robbing adjacent houses.

Input: [2,7,9,3,1]
Output: 12 (2+9+1)

Minimum operations to convert word1 to word2.

Input: word1 = “horse”, word2 = “ros”
Output: 3

Design LRU Cache with O(1) get and put.

Design simplified Twitter with follow, unfollow, post, getNewsFeed.

import heapq
def merge_k_lists(lists):
heap = []
for i, lst in enumerate(lists):
if lst:
heapq.heappush(heap, (lst.val, i, lst))
dummy = ListNode(0)
current = dummy
while heap:
val, i, node = heapq.heappop(heap)
current.next = node
current = current.next
if node.next:
heapq.heappush(heap, (node.next.val, i, node.next))
return dummy.next
class Codec:
def serialize(self, root):
def dfs(node):
if not node:
return ['null']
return [str(node.val)] + dfs(node.left) + dfs(node.right)
return ','.join(dfs(root))
def deserialize(self, data):
nodes = iter(data.split(','))
def dfs():
val = next(nodes)
if val == 'null':
return None
node = TreeNode(int(val))
node.left = dfs()
node.right = dfs()
return node
return dfs()
import heapq
class MedianFinder:
def __init__(self):
self.small = [] # max heap (negated)
self.large = [] # min heap
def addNum(self, num):
heapq.heappush(self.small, -num)
heapq.heappush(self.large, -heapq.heappop(self.small))
if len(self.large) > len(self.small):
heapq.heappush(self.small, -heapq.heappop(self.large))
def findMedian(self):
if len(self.small) > len(self.large):
return -self.small[0]
return (-self.small[0] + self.large[0]) / 2

Apple Preparation Guide

Complete preparation strategy. View Guide →


Practice these problems thoroughly for Apple interviews!

Last updated: February 2026