Combinatorics Problems for Coding Interviews
70 Combinatorics problems from real coding interviews, each with test cases you can run online. By difficulty they split into 20 basic, 35 intermediate and 15 advanced. The companies that ask them most often are Google, Amazon, Microsoft, Bloomberg.
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
- Pascal Triangle Value (Intermediate)
- Max Chunks to Make Sorted (Advanced)
- Permutation Inside a String (Intermediate)
- Coin Change Ways (Intermediate)
- Next Permutation (Intermediate)
- Minimum Operations to Sort by Reversals (Intermediate)
- Count Subarrays With Median K (Basic)
- Combination Sum IV (Intermediate)
- Count Vowel Permutations (Intermediate)
- Ways to Reorder Array to Get Same BST (Advanced)
- Validate Stack Sequences (Intermediate)
- Prime Arrangements (Basic)
- 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)
- Letter Case Permutation (Basic)
- Combinations (Intermediate)
- Permutation Rank (Advanced)
- Couples Holding Hands (Advanced)
- K Inverse Pairs Array (Advanced)
- Count Increasing Quadruplets (Advanced)
- Stirling Numbers of the Second Kind (Intermediate)
- Derangements Count (Basic)
- DI String Valid Permutations (Advanced)
- Palindrome Permutation Check (Basic)
- Build Array From Permutation (Basic)
- Prefix Common Array (Basic)
- Decode XORed Permutation (Advanced)
- Largest Combination With Positive AND (Intermediate)
- Binomial Coefficient Queries (Intermediate)
- Collecting Numbers Rounds (Basic)
- Minimum Cost to Make Array a Permutation (Basic)
- Expected Inversions in Random Permutation (Basic)
- 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)
- Binomial Modulo Small Prime (Advanced)
- Eulerian Number Modulo (Advanced)
- 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)
- Count Permutation Cycles (Basic)
- Permutation Parity (Basic)
- Inverse of a Permutation (Basic)
- Compose Two Permutations (Basic)
- Fixed Points After K Applications (Intermediate)
- Derangement Check (Basic)
- Count 132-Avoiding Permutations (Advanced)
- Permutations With Exactly K Fixed Points (Advanced)
- Permutation Cycle Type (Basic)
- Kendall Tau Distance Between Permutations (Advanced)
- Permutation Is a Single Cycle (Basic)
- Position After K Shuffles (Basic)
- Centralizer Size of Permutation (Advanced)
- Binomial Expansion Coefficient (Intermediate)
- Bit Reversal Index (Basic)
- Catalan Number Modulo (Intermediate)
- Derangement Count Modulo (Intermediate)
- Stirling Number of the Second Kind Modulo (Intermediate)
- Unsigned Stirling Cycle Number Modulo (Intermediate)
- Lexicographic Rank of a Word (Advanced)
- Combination Lock Minimum Turns (Basic)
Related
- Basic Combinatorics problems
- Intermediate Combinatorics problems
- Advanced Combinatorics problems
- Practice coding problems online
- All interview guides
Frequently asked questions
How do I get good at combinatorics 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 combinatorics 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.