Recursion Interview Problems
Recursion Interview Problems
Here are some classic recursion problems that are frequently asked in coding interviews,
especially for companies like Google, Amazon, and Microsoft:
Fibonacci Sequence
Given n , return the n -th Fibonacci number using recursion.
Power of a Number
Implement power(x, n) to calculate x^n using recursion.
Combination Sum
Given an array of distinct integers and a target, find all unique combinations where the
chosen numbers sum to the target.
Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed
parentheses.
1/13
3. Divide and Conquer Recursion:
Merge Sort Algorithm
Implement merge sort to sort an array.
Sudoku Solver
Solve a Sudoku puzzle using recursion and backtracking.
N-Queens Problem
Place n queens on an n x n chessboard so that no two queens threaten each other.
2/13
6. Tree and Graph Recursion:
Binary Tree Traversals (Inorder, Preorder, Postorder)
Would you like to dive deeper into any of these problems or need help with solutions?
same on arrays
Here are some commonly asked array problems in coding interviews, ranging from easy to
hard, covering key concepts like two pointers, sliding window, divide and conquer,
dynamic programming, and greedy algorithms.
Reverse an Array
Reverse the given array in-place without using extra space.
3/13
🧮 2. Two Pointers Approach
Two Sum (Sorted Array)
Given a sorted array and a target, find two numbers that sum up to the target.
3Sum Problem
Find all unique triplets in the array that give the sum of zero.
4/13
Search in Rotated Sorted Array
Given a rotated sorted array, find the index of a given target.
💡 5. Greedy Algorithms
Jump Game
Given an array of non-negative integers, where each element represents your maximum jump
length, determine if you can reach the last index.
5/13
🌟 7. Advanced Problems
Median of Two Sorted Arrays (Hard)
Given two sorted arrays, find the median of the combined sorted array in O(log(min(n, m)))
time.
Would you like to see solutions, explanations, or code for any of these problems in C++? 🚀
same on strings
Here are some of the most frequently asked string problems in coding interviews,
categorized by techniques like two pointers, sliding window, dynamic programming,
recursion, and more. These problems help test your skills in manipulating strings efficiently.
Valid Anagram
Check if two strings are anagrams of each other (same characters in a different order).
6/13
Count and Say
Given an integer n , generate the n -th term of the "count and say" sequence.
Valid Palindrome II
Given a string, return true if you can make it a palindrome by deleting at most one character.
Permutation in String
Given two strings s1 and s2 , return true if s2 contains a permutation of s1 .
Wildcard Matching
Implement wildcard pattern matching with support for ? and * .
Palindrome Partitioning
Partition a string such that every substring is a palindrome and return the minimum number
of cuts needed.
8/13
Restore IP Addresses
Given a string containing digits, return all possible valid IP address combinations.
💡 7. Trie-Based Problems
Implement Trie (Prefix Tree)
Design and implement a Trie with insert() , search() , and startsWith() functions.
Word Search II
Given a 2D board and a list of words, find all words present in the board using Trie and
backtracking.
Rabin-Karp Algorithm
Search for a pattern in a string using a rolling hash function.
Manacher’s Algorithm
Find the longest palindromic substring in linear time.
9/13
Would you like me to explain or code any specific problem in C++? 🚀
same on linked list
Here are some commonly asked linked list problems in coding interviews, categorized by
difficulty and key techniques like two pointers, recursion, stack, and advanced algorithms.
These problems help you master pointer manipulation, which is a critical skill for interviews.
10/13
Partition List
Given a linked list and a value x , partition it so that all nodes less than x come before nodes
greater than or equal to x .
🔄 3. Recursion-Based Problems
Reverse Linked List II (Reverse a Sublist)
Reverse a portion of the linked list from position m to n .
📚 4. Stack-Based Problems
Next Greater Node in Linked List
Find the next greater value for each node in the linked list.
11/13
LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache using a doubly
linked list and a hash map.
Reorder List
Rearrange a linked list from L0 → L1 → … → Ln-1 → Ln to L0 → Ln → L1 → Ln-1 → L2 →
Ln-2 .
🗂️ 8. Interview-Focused Problems
LRU Cache Design (LeetCode 146)
12/13
Odd Even Linked List (LeetCode 328)
Would you like me to explain, code, or solve any of these problems in C++? 🚀
13/13