Combinatorics LeetCode Problems: All 32,
With Python Solutions

Every problem in this library that LeetCode tags Combinatorics. 27 of them carry a complete Python solution, a worked example and the time and space complexity of the approach.

Easy
2
Medium
13
Hard
17
1 pattern

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.

Eyes only

When the Combinatorics problem arrives live.

In the live round, Stealth Interview reads the 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 says. It's a desktop app for macOS and Windows, invisible to screen sharing.

Combinatorics problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (2)

Easy problems
No.Problem
1863Sum of All Subset XOR Totals
2928Distribute Candies Among Children I

Medium (13)

Medium problems
No.Problem
0062Unique Paths
1201Ugly Number III
1621Number of Sets of K Non-Overlapping Line Segments
1641Count Sorted Vowel Strings
2063Vowels of All Substrings
2221Find Triangular Sum of an Array
2400Number of Ways to Reach a Position After Exactly k Steps
2597The Number of Beautiful Subsets
2929Distribute Candies Among Children II
2930Number of Strings Which Can Be Rearranged to Contain Substring
0634Find the Derangement of An ArrayPremium
2539Count the Number of Good SubsequencesPremium
2638Count the Number of K-Free SubsetsPremium

Hard (17)

Hard problems
No.Problem
0458Poor Pigs
0920Number of Music Playlists
1359Count All Valid Pickup and Delivery Options
1467Probability of a Two Boxes Having The Same Number of Distinct Balls
1569Number of Ways to Reorder Array to Get Same BST
1643Kth Smallest Instructions
1735Count Ways to Make Array With Product
1830Minimum Number of Operations to Make String Sorted
1866Number of Ways to Rearrange Sticks With K Sticks Visible
1916Count Ways to Build Rooms in an Ant Colony
2338Count the Number of Ideal Arrays
2514Count Anagrams
2842Count K-Subsequences of a String With Maximum Beauty
2954Count the Number of Infection Sequences
2963Count the Number of Good Partitions
2912Number of Ways to Reach Destination in the GridPremium
2927Distribute Candies Among Children IIIPremium