#### most common apple coding interview questions

#### Below is a list of the 15 most frequently asked questions in an apple interview

For detailed solutions to each question, you can visit

Grokking the Coding Interview: Patterns for Coding Questions

# Arrays

#### determine if the sum of three integers is equal to the given value

Problem Statement

Given an array of integers and a value, determine if there are any three integers in the array whose sum equals the given value.

#### find the smallest subarray whose sum is greater than or equal to a given value

# Problem Statement

#

Given an array of positive numbers and a positive number ‘S’, find the length of the smallest contiguous subarray whose sum is greater than or equal to ‘S’. Return 0, if no such subarray exists.

# linked lists

#### add two integers

# Problem Statement

#

Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit), add them and return the resulting linked list.

#### merge two sorted linked lists

# Problem Statement

#

Given two sorted linked lists, merge them so that the resulting linked list is also sorted.

# trees

#### determine if two binary trees are identical

# Problem Statement

#

Given the roots of two binary trees, determine if these trees are identical or not. Identical trees have the same layout and data at each node.

#### find the minimum depth of a binary tree

# Problem Statement

#

Find the minimum depth of a binary tree. The minimum depth is the number of nodes along the shortest path from the root node to the nearest leaf node.

# strings

#### longest substring with no repeating characters

# Problem Statement

#

Given a string, find the length of the longest substring which has no repeating characters.

#### given a string, rearrange it so that no characters repeat

# Problem Statement

#

Given a string, find if its letters can be rearranged in such a way that no two same characters come next to each other.

# dynamic programming

#### find the maximum sum of a subarray

# Problem Statement

#

Given an array of positive numbers and a positive number ‘k’, find the maximum sum of any contiguous subarray of size ‘k’.

# Math and stats

#### happy number

# Problem Statement

#

Any number will be called a happy number if, after repeatedly replacing it with a number equal to the sum of the square of all of its digits, leads us to number ‘1’. All other (not-happy) numbers will never reach ‘1’. Instead, they will be stuck in a cycle of numbers which does not include ‘1’.

# backtracking

#### find all sum combinations

# Problem Statement

#

Given a positive integer, target, print all possible combinations of positive integers that sum u to the targetnumber.

# Graphs

#### clone a directed graph

# Problem Statement

#

# design

#### implement a lru cache

# Problem Statement

#

Least Recently Used (LRU) is a common caching strategy. It defines the policy to evict elements from the cache to make room for new elements when the cache is full, meaning it discards the least recently used items first.

# sorting and searching

#### search in rotated array

# Problem Statement

#

Search for a given number in a sorted array that has been rotated by some arbitrary number. Return -1 if the number does not exist. Assume that the array does not contain duplicates.

#### merge overlapping intervals

# Problem Statement

#

Given a list of intervals, merge all the overlapping intervals to produce a list that has only mutually exclusive intervals.

For detailed solutions to each question, you can visit

Grokking the Coding Interview: Patterns for Coding Questions

have you been asked a question that is not included here in your apple interview?

please share with us:

Need help preparing for the interview?

Check out the Definitive Interview Prep Roadmap,

written and reviewed by real hiring managers.