Combinatorics LeetCode Problems: All 32, With Python Solutions
Every problem in this library that LeetCode tags Combinatorics — 32 in total, 27 of them with a complete Python solution, a worked example and the time and space complexity of the approach.
- 32 problems
- 2 Easy
- 13 Medium
- 17 Hard
How Combinatorics problems are solved
A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Combinatorics problems — each one explains the approach, gives a Python template and states its complexity.
- Math and Number Theory — Find the closed form, the invariant, or the modular identity — and skip the loop entirely.
Combinatorics problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Easy (2)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 1863 | Sum of All Subset XOR Totals | Easy | Bit Manipulation, Array, Math +3 |
| 2928 | Distribute Candies Among Children I | Easy | Math, Combinatorics, Enumeration |
Medium (13)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 62 | Unique Paths | Medium | Math, Dynamic Programming, Combinatorics |
| 1201 | Ugly Number III | Medium | Math, Binary Search, Combinatorics +1 |
| 1621 | Number of Sets of K Non-Overlapping Line Segments | Medium | Math, Dynamic Programming, Combinatorics |
| 1641 | Count Sorted Vowel Strings | Medium | Math, Dynamic Programming, Combinatorics |
| 2063 | Vowels of All Substrings | Medium | Math, String, Dynamic Programming +1 |
| 2221 | Find Triangular Sum of an Array | Medium | Array, Math, Combinatorics +1 |
| 2400 | Number of Ways to Reach a Position After Exactly k Steps | Medium | Math, Dynamic Programming, Combinatorics |
| 2597 | The Number of Beautiful Subsets | Medium | Array, Hash Table, Math +4 |
| 2929 | Distribute Candies Among Children II | Medium | Math, Combinatorics, Enumeration |
| 2930 | Number of Strings Which Can Be Rearranged to Contain Substring | Medium | Math, Dynamic Programming, Combinatorics |
| 634 | Find the Derangement of An ArrayPremium | Medium | Math, Dynamic Programming, Combinatorics |
| 2539 | Count the Number of Good SubsequencesPremium | Medium | Hash Table, Math, String +2 |
| 2638 | Count the Number of K-Free SubsetsPremium | Medium | Array, Math, Dynamic Programming +2 |
Hard (17)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 458 | Poor Pigs | Hard | Math, Dynamic Programming, Combinatorics |
| 920 | Number of Music Playlists | Hard | Math, Dynamic Programming, Combinatorics |
| 1359 | Count All Valid Pickup and Delivery Options | Hard | Math, Dynamic Programming, Combinatorics |
| 1467 | Probability of a Two Boxes Having The Same Number of Distinct Balls | Hard | Array, Math, Dynamic Programming +3 |
| 1569 | Number of Ways to Reorder Array to Get Same BST | Hard | Tree, Union Find, Binary Search Tree +7 |
| 1643 | Kth Smallest Instructions | Hard | Array, Math, Dynamic Programming +1 |
| 1735 | Count Ways to Make Array With Product | Hard | Array, Math, Dynamic Programming +2 |
| 1830 | Minimum Number of Operations to Make String Sorted | Hard | Math, String, Combinatorics |
| 1866 | Number of Ways to Rearrange Sticks With K Sticks Visible | Hard | Math, Dynamic Programming, Combinatorics |
| 1916 | Count Ways to Build Rooms in an Ant Colony | Hard | Tree, Graph, Topological Sort +3 |
| 2338 | Count the Number of Ideal Arrays | Hard | Math, Dynamic Programming, Combinatorics +1 |
| 2514 | Count Anagrams | Hard | Hash Table, Math, String +2 |
| 2842 | Count K-Subsequences of a String With Maximum Beauty | Hard | Greedy, Hash Table, Math +2 |
| 2954 | Count the Number of Infection Sequences | Hard | Array, Math, Combinatorics |
| 2963 | Count the Number of Good Partitions | Hard | Array, Hash Table, Math +1 |
| 2912 | Number of Ways to Reach Destination in the GridPremium | Hard | Math, Dynamic Programming, Combinatorics |
| 2927 | Distribute Candies Among Children IIIPremium | Hard | Math, Combinatorics |
Keep exploring
- Array1,569
- String672
- Hash Table588
- Math485
- Dynamic Programming481
- Sorting392
- Greedy346
- Depth-First Search289
- Binary Search253
- Database249
- Tree225
- Breadth-First Search223
- Matrix216
- Two Pointers201
- Bit Manipulation194
- Binary Tree174
- Heap (Priority Queue)163
- Prefix Sum157
- Stack157
- Simulation144
- Graph138
- Counting126
- Design122
- Sliding Window116
When the Combinatorics problem arrives live
Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.