Intermediate Backtracking Problems for Coding Interviews
40 intermediate Backtracking problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 40 intermediate and 0 advanced. The companies that ask them most often are Amazon, Google, Bloomberg, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Permutation Inside a String (Intermediate)
- Count Subsets With Given XOR (Intermediate)
- Coin Change Ways (Intermediate)
- Partition Equal Subset Sum (Intermediate)
- Next Permutation (Intermediate)
- Minimum Operations to Sort by Reversals (Intermediate)
- Linked List Components (Intermediate)
- Ones and Zeroes (Intermediate)
- Combination Sum IV (Intermediate)
- Count Vowel Permutations (Intermediate)
- Validate Stack Sequences (Intermediate)
- Permutations of Distinct Values (Intermediate)
- Combination Sum (Intermediate)
- Combination Sum II (Intermediate)
- Combination Sum III (Intermediate)
- Letter Combinations of a Phone Number (Intermediate)
- Beautiful Arrangement (Intermediate)
- Combinations (Intermediate)
- Count Subsets With Sum K (Intermediate)
- Largest Combination With Positive AND (Intermediate)
- Subset Sum Count to Target (Intermediate)
- Minimum Difference Between Two Subset Sums (Intermediate)
- Smallest Unreachable Subset Sum (Intermediate)
- Expected Cycles in Random Permutation (Intermediate)
- Next Lexicographic Permutation of String (Intermediate)
- Stack Sortable Permutation Check (Intermediate)
- Unsigned Stirling Number of the First Kind (Intermediate)
- Involution Count Modulo (Intermediate)
- Count Subarrays That Are Permutations (Intermediate)
- Lehmer Code of Permutation (Intermediate)
- Permutation From Lehmer Code (Intermediate)
- Inversion Table of Permutation (Intermediate)
- Order of a Permutation (Intermediate)
- Permutation Raised to Power K (Intermediate)
- Fixed Points After K Applications (Intermediate)
- Sum of XOR of All Subsets (Intermediate)
- Sum of AND Over All Subsets (Intermediate)
- Derangement Count Modulo (Intermediate)
- Subsets With Sum Divisible by K (Intermediate)
- Unsigned Stirling Cycle Number Modulo (Intermediate)
Related
Frequently asked questions
How do I get good at backtracking problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run backtracking problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.