Advanced Backtracking Problems for Coding Interviews
25 advanced Backtracking problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 0 intermediate and 25 advanced. The companies that ask them most often are Google, Amazon, Meta, 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
- Coin Change Ways (Advanced)
- Max Chunks to Make Sorted (Advanced)
- Largest Divisible Subset Size (Advanced)
- Exact Cover Solver (Advanced)
- Profitable Schemes (Advanced)
- Ways to Reorder Array to Get Same BST (Advanced)
- N-Queens Count (Advanced)
- Permutation Rank (Advanced)
- Couples Holding Hands (Advanced)
- Maximum Height by Stacking Cuboids (Advanced)
- K Inverse Pairs Array (Advanced)
- Count Increasing Quadruplets (Advanced)
- DI String Valid Permutations (Advanced)
- Decode XORed Permutation (Advanced)
- Maximum Subset XOR (Advanced)
- Number of Distinct Subset XOR Values (Advanced)
- Count Subsets With Zero AND (Advanced)
- Eulerian Number Modulo (Advanced)
- Closest Subset Sum to Target Meet in the Middle (Advanced)
- Count 132-Avoiding Permutations (Advanced)
- Permutations With Exactly K Fixed Points (Advanced)
- Kendall Tau Distance Between Permutations (Advanced)
- Centralizer Size of Permutation (Advanced)
- Subsets With XOR Equal to K (Advanced)
- Lexicographic Rank of a Word (Advanced)
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.