Talentd
FleetCode
Make and follow sheets.Sign in

Combinatorics Problems (63)

Problems tagged with Combinatorics. Start with the easy ones, then move to medium and hard.

3 Easy20 Medium40 Hard

Learn these first

1
Math

Combinatorics relies heavily on mathematical reasoning such as factorials, modular arithmetic, and binomial coefficients. Understanding these foundations helps you derive counting formulas efficiently.

2
Bitmask

Bitmasking is commonly used to represent subsets and iterate through combinations efficiently in combinatorics-related problems.

3
Recursion

Many combinatorial problems naturally use recursive thinking to explore combinations and permutations before optimizing them with mathematical counting.

4
Number Theory

Concepts like modular inverses and modular exponentiation are frequently required to compute large combinatorial values under constraints.

5
Dynamic Programming

DP is often used to compute combinatorial counts efficiently, such as counting paths, sequences, or valid configurations with overlapping subproblems.

TitleSolutionAcceptDifficultyTopics
458. Poor PigsVideo
Solution59.4%Hard
Solution44.7%Hard
Array, Combinatorics +2· 1 company
2514. Count AnagramsVideo
Solution38.4%Hard
Combinatorics, Counting +3· 1 company
Solution57.3%Hard
Combinatorics, Math· 2 companies
Solution58.4%Hard
Array, Binary Search +6· 1 company
3470. Permutations IVVideo
–32.8%Hard
–27.5%Hard
Array, Combinatorics +4· 2 companies
Showing 1–40 of 40

More about Combinatorics

Combinatorics is a branch of mathematics focused on counting, arranging, and selecting objects. In data structures and algorithms (DSA), combinatorics helps you determine how many ways something can happen without explicitly generating every possibility. Instead of brute-forcing all outcomes, combinatorial formulas and reasoning allow you to compute results efficiently. This makes it extremely valuable when solving problems that involve combinations, permutations, subsets, or counting valid configurations.

In coding interviews, combinatorics frequently appears in problems involving subsets, arrangements, probability, and counting paths or structures. Interviewers often test whether you can recognize patterns like "choose k from n", factorial-based permutations, or counting cases without duplication. These ideas commonly appear alongside techniques such as Dynamic Programming, Backtracking, and Recursion, where counting or enumerating possibilities is a key part of the solution.

Some of the most common combinatorics techniques used in algorithm problems include:

  • Permutations and combinations using factorial formulas or nCr calculations.
  • Counting with constraints such as avoiding duplicates or restricting positions.
  • Stars and bars style reasoning for distributing items into groups.
  • Subset enumeration often paired with Bitmask techniques.
  • Mathematical counting formulas that avoid exponential enumeration.

Combinatorics is particularly useful when the number of possibilities grows exponentially and generating them directly would be too slow. Instead of iterating through every option, you derive a formula or recurrence to compute the answer in constant or polynomial time. Many advanced problems also combine combinatorics with Math and modular arithmetic to handle very large counts.

Practicing combinatorics problems helps you build strong analytical thinking and pattern recognition—two skills that are essential for technical interviews at top companies.

Combinatorics: common questions

Do combinatorics problems require advanced math?

Most interview-level combinatorics problems rely on basic counting formulas and logical reasoning rather than advanced mathematics. However, understanding factorials, binomial coefficients, and modular arithmetic is often necessary.

What is the best way to learn combinatorics for DSA?

Start by mastering factorials, permutations, and combinations, then practice problems involving subset counting and constrained arrangements. Gradually move to problems that combine combinatorics with dynamic programming or mathematical optimization.

Is combinatorics important for FAANG coding interviews?

Yes. While not as frequent as arrays or graphs, combinatorics appears in many medium and hard interview questions, especially those involving counting possibilities, probability, or large configuration spaces.

What are common combinatorics patterns in DSA problems?

Typical patterns include permutation generation, combination counting (nCr), subset enumeration, stars and bars distribution problems, and counting arrangements with restrictions or duplicates.

What are the most common combinatorics problems in coding interviews?

Common interview problems involve counting subsets, calculating permutations or combinations, distributing items into groups, and counting paths or arrangements with constraints. Many also combine combinatorics with dynamic programming or recursion to avoid brute force enumeration.