12 Common Recursion Interview Questions (with Video Solutions)

Recursion Interview Questions

Coding interview questions requiring recursion may be some of the hardest questions out there. But they are also some of the most important.

Interviewers love to ask recursion interview questions because they truly push interviewees to the limit, and allow interviewers to differentiate between those candidates who are just good and those who are exceptional.

Not only that, but recursive techniques tend to bleed into almost every other category of question.

Strings? Edit Distance or Longest Common Substring.

Trees and Graphs? Depth First Search.

Dynamic Programming? Recursion is the first step of the FAST Method.

Suffice to say, it is absolutely essential that you be prepared to solve recursion interview questions in your interview. It is almost guaranteed that you will see at least one or two recursive problems at any given onsite interview.

In this post, I will walk you through 12 of the most common recursion interview questions that you might see in your coding interview. If you understand these problems and the underlying strategies, you will be well on your way to nailing any recursive problem.

As you go through each of these problems, I would highly encourage you to attempt the problem on your own before watching the solution. Ideally, you should simply be using the solutions as a reference.

Protip: If you’re still new to recursion, check out our Ultimate Guide to Recursion first


Check out the problems:

1. Making Change

Given an input amount of change x, write a function to determine the minimum number of coins required to make that amount of change.

eg. (using American coins)


2. Binary Search Tree Verification

Given a binary tree, write a function to test if the tree is a binary search tree.



Random Binary Tree


Binary Tree Validation invalid

3. Find All Permutations of an Input

Write a function that returns all permutations of a given list.



4. Balanced Binary Tree

Given a binary tree, write a function to determine whether the tree is balanced.


All subtrees are balanced
Balanced Binary Tree graph

5. Print a Linked List in Reverse Order

Given a linked list, write a function that prints the nodes of the list in reverse order.



6. Longest Consecutive Branch in a Tree

Given a tree, write a function to find the length of the longest branch of nodes in increasing consecutive order.


longest branch tree


7. Tree to Doubly Linked List

Given a tree, write a function to convert it into a circular doubly linked list from left to right by only modifying the existing pointers.


Lowest Common Ancestor tree

<- 4 <-> 2 <-> 5 <-> 1 <-> 6 <-> 3 <-> 7 ->


8. Nth Fibonacci Number

Given an integer n, write a function to compute the nth Fibonacci number.



9. Reverse a Stack

Given a stack, reverse the items without creating any additional data structures.


reverse(1->2->3) = 3->2->1


10. Compute the Sum

Given two integers, write a function to sum the numbers without using any arithmetic operators.


11. Find the Lowest Common Ancestor

Given two nodes in a binary tree, write a function to find the lowest common ancestor.


Lowest Common Ancestor tree


12. Select a Random Binary Tree Node

Implement a binary tree with a method getRandomNode() that returns a random node.


Random Binary Tree



Have you seen any of these problems in an interview before? Comment below and let me know!

Don't do another coding interview...​

…Until you’ve mastered these 50 questions!

50 Coding Interview Questions Cover
Sam Gavis-Hughson

Sam Gavis-Hughson

Sam, founder of Byte by Byte, helps software engineers successfully interview for jobs at top tech companies. Sam has helped thousands of students through his blog and free content -- as well as 400+ paying students -- land jobs at companies such as Google, Amazon, Microsoft, Bloomberg, Uber, and more.