Preptide

Combinatorics

Interview prep for combinatorics including permutations, combinations, Catalan numbers, and advanced counting techniques

Fundamental Concepts

Basic Counting Principles

Addition Principle: If there are nn ways to do task A and mm ways to do task B, and these tasks are mutually exclusive, then there are n+mn + m ways to do either task A or task B.

Multiplication Principle: If there are nn ways to do task A and mm ways to do task B, then there are n×mn \times m ways to do both tasks in sequence.

Subtraction Principle: If there are nn ways to do a task without restrictions and mm ways that violate certain restrictions, then there are nmn - m ways to do the task satisfying the restrictions.

Division Principle: If there are nn ways to perform a task, but each outcome is counted kk times due to symmetry, then there are nk\frac{n}{k} distinct outcomes.

Permutations

Permutations of n distinct objects:

P(n)=n!P(n) = n!

Permutations of r objects from n distinct objects (order matters):

P(n,r)=n!(nr)!=n(n1)(n2)(nr+1)P(n, r) = \frac{n!}{(n-r)!} = n(n-1)(n-2)\cdots(n-r+1)

Permutations with repetition: Arranging nn objects where there are n1n_1 of type 1, n2n_2 of type 2, ..., nkn_k of type k:

n!n1!n2!nk!\frac{n!}{n_1! \cdot n_2! \cdots n_k!}

Combinations

Combinations of r objects from n (order doesn't matter):

C(n,r)=(nr)=n!r!(nr)!C(n, r) = \binom{n}{r} = \frac{n!}{r!(n-r)!}

Properties:

  • (nr)=(nnr)\binom{n}{r} = \binom{n}{n-r} (symmetry)
  • (nr)=(n1r1)+(n1r)\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r} (Pascal's identity)
  • r=0n(nr)=2n\sum_{r=0}^{n} \binom{n}{r} = 2^n (sum of binomial coefficients)
  • (n0)=(nn)=1\binom{n}{0} = \binom{n}{n} = 1

Stars and Bars

Problem: Distribute nn identical objects into kk distinct bins.

Non-negative integers (bins can be empty):

(n+k1k1)=(n+k1n)\binom{n+k-1}{k-1} = \binom{n+k-1}{n}

Positive integers (each bin must have at least one):

(n1k1)\binom{n-1}{k-1}

Intuition: Stars represent objects, bars separate bins. For nn stars and k1k-1 bars, choose positions for the bars.

Essential Identities and Formulas

Binomial Theorem

(x+y)n=k=0n(nk)xnkyk(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k

Special cases:

  • (1+x)n=k=0n(nk)xk(1 + x)^n = \sum_{k=0}^{n} \binom{n}{k} x^k
  • (1+1)n=2n=k=0n(nk)(1 + 1)^n = 2^n = \sum_{k=0}^{n} \binom{n}{k}
  • (11)n=0=k=0n(1)k(nk)(1 - 1)^n = 0 = \sum_{k=0}^{n} (-1)^k \binom{n}{k} (for n>0n > 0)

Multinomial Theorem

(x1+x2++xk)n=(nn1,n2,,nk)x1n1x2n2xknk(x_1 + x_2 + \cdots + x_k)^n = \sum \binom{n}{n_1, n_2, \ldots, n_k} x_1^{n_1} x_2^{n_2} \cdots x_k^{n_k}

where the sum is over all non-negative integers n1+n2++nk=nn_1 + n_2 + \cdots + n_k = n, and:

(nn1,n2,,nk)=n!n1!n2!nk!\binom{n}{n_1, n_2, \ldots, n_k} = \frac{n!}{n_1! n_2! \cdots n_k!}

Vandermonde's Identity

(m+nr)=k=0r(mk)(nrk)\binom{m+n}{r} = \sum_{k=0}^{r} \binom{m}{k} \binom{n}{r-k}

Interpretation: Choosing rr objects from two groups of sizes mm and nn.

Hockey Stick Identity

i=rn(ir)=(n+1r+1)\sum_{i=r}^{n} \binom{i}{r} = \binom{n+1}{r+1}

Interpretation: Sum of diagonal entries in Pascal's triangle.

The 12-Fold Way

Counting the number of ways to place nn balls into kk bins:

BallsBinsAny arrangementInjective (≤1 per bin)Surjective (≥1 per bin)
DistinguishableDistinguishableknk^nkn=k!(kn)!k^{\underline{n}} = \frac{k!}{(k-n)!}k!S(n,k)k! \cdot S(n,k)
IndistinguishableDistinguishable(n+k1k1)\binom{n+k-1}{k-1}(kn)\binom{k}{n}(n1k1)\binom{n-1}{k-1}
DistinguishableIndistinguishablej=1kS(n,j)\sum_{j=1}^{k} S(n,j)11 if nkn \leq k, else 00S(n,k)S(n,k)
IndistinguishableIndistinguishablep(n,k)p(n,k)11 if nkn \leq k, else 00p(n,k)p(n,k)

Notation:

  • knk^{\underline{n}} is the falling factorial: k(k1)(k2)(kn+1)k(k-1)(k-2)\cdots(k-n+1)
  • S(n,k)S(n,k) is the Stirling number of the second kind (partitions of nn into kk non-empty subsets)
  • p(n,k)p(n,k) is the partition function (partitions of nn into at most kk parts)

Stirling Numbers of the Second Kind

Number of ways to partition nn objects into kk non-empty subsets:

S(n,k)=1k!j=0k(1)kj(kj)jnS(n,k) = \frac{1}{k!} \sum_{j=0}^{k} (-1)^{k-j} \binom{k}{j} j^n

Recurrence:

S(n,k)=kS(n1,k)+S(n1,k1)S(n,k) = k \cdot S(n-1,k) + S(n-1,k-1)

Boundary conditions: S(n,0)=0S(n,0) = 0 for n>0n > 0, S(0,0)=1S(0,0) = 1, S(n,n)=1S(n,n) = 1

Catalan Numbers

Definition

The nn-th Catalan number is:

Cn=1n+1(2nn)=(2n)!(n+1)!n!C_n = \frac{1}{n+1} \binom{2n}{n} = \frac{(2n)!}{(n+1)! \cdot n!}

First few values: C0=1,C1=1,C2=2,C3=5,C4=14,C5=42,...C_0 = 1, C_1 = 1, C_2 = 2, C_3 = 5, C_4 = 14, C_5 = 42, ...

Recurrence relation:

Cn=i=0n1CiCn1iC_n = \sum_{i=0}^{n-1} C_i C_{n-1-i}

with C0=1C_0 = 1.

Generating function:

G(x)=n=0Cnxn=114x2xG(x) = \sum_{n=0}^{\infty} C_n x^n = \frac{1 - \sqrt{1-4x}}{2x}

Applications of Catalan Numbers

  1. Number of valid parenthesizations of nn pairs of parentheses
  2. Number of binary trees with nn internal nodes
  3. Number of ways to triangulate a convex (n+2)(n+2)-gon
  4. Number of monotonic lattice paths from (0,0)(0,0) to (n,n)(n,n) that don't cross the diagonal (Dyck paths)
  5. Number of ways to connect 2n2n points on a circle with nn non-crossing chords
  6. Number of permutations of [n][n] that avoid the pattern 123123 (or any pattern of length 3)

Dyck Paths and Lattice Path Counting

Dyck Paths

A Dyck path is a lattice path from (0,0)(0,0) to (n,n)(n,n) using steps (1,0)(1,0) (right) and (0,1)(0,1) (up) that never goes above the diagonal y=xy = x.

Count: The number of Dyck paths from (0,0)(0,0) to (n,n)(n,n) is CnC_n (the nn-th Catalan number).

Proof technique: Reflection principle (cycle lemma).

General Lattice Path Counting

Problem: Count paths from (0,0)(0,0) to (m,n)(m,n) using right (1,0)(1,0) and up (0,1)(0,1) steps.

Answer:

(m+nm)=(m+nn)\binom{m+n}{m} = \binom{m+n}{n}

Intuition: Total steps = m+nm + n, choose which mm are "right" (or which nn are "up").

Lattice Paths with Barriers

Problem: Count paths from (0,0)(0,0) to (m,n)(m,n) that don't touch or cross a barrier.

Technique: Reflection principle (also called the ballot problem or cycle lemma).

Example: Paths from (0,0)(0,0) to (n,n)(n,n) that stay strictly below the diagonal:

1n+1(2nn)=Cn\frac{1}{n+1}\binom{2n}{n} = C_n

Ballot Problem

In an election, candidate A receives aa votes and candidate B receives bb votes, with a>ba > b. The number of ways the ballots can be ordered such that A is always ahead is:

aba+b(a+ba)\frac{a - b}{a + b} \binom{a+b}{a}

Inclusion-Exclusion Principle

General Formula

For events A1,A2,...,AnA_1, A_2, ..., A_n:

i=1nAi=iAii<jAiAj+i<j<kAiAjAk+(1)n1A1A2An\left| \bigcup_{i=1}^{n} A_i \right| = \sum_{i} |A_i| - \sum_{i<j} |A_i \cap A_j| + \sum_{i<j<k} |A_i \cap A_j \cap A_k| - \cdots + (-1)^{n-1} |A_1 \cap A_2 \cap \cdots \cap A_n|

Compact form:

i=1nAi=S[n](1)S+1iSAi\left| \bigcup_{i=1}^{n} A_i \right| = \sum_{\emptyset \neq S \subseteq [n]} (-1)^{|S|+1} \left| \bigcap_{i \in S} A_i \right|

Derangements

A derangement is a permutation where no element appears in its original position.

Number of derangements of nn objects:

Dn=n!k=0n(1)kk!=n!(10!11!+12!13!++(1)nn!)D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!} = n! \left( \frac{1}{0!} - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots + \frac{(-1)^n}{n!} \right)

Approximation: Dnn!eD_n \approx \frac{n!}{e}

Recurrence:

Dn=(n1)(Dn1+Dn2)D_n = (n-1)(D_{n-1} + D_{n-2})

with D0=1,D1=0D_0 = 1, D_1 = 0.

Probability: The probability that a random permutation is a derangement approaches 1/e0.3681/e \approx 0.368 as nn \to \infty.

Burnside's Lemma (Pólya Enumeration)

Burnside's Lemma

Problem: Count distinct objects under group symmetries.

Formula: Let GG be a group acting on a set XX. The number of distinct objects (orbits) is:

X/G=1GgGXg|X/G| = \frac{1}{|G|} \sum_{g \in G} |X^g|

where XgX^g is the set of elements fixed by symmetry gg.

Intuition: Average number of elements fixed by each symmetry.

Common Applications

Necklace problem: Count distinct necklaces with nn beads and kk colors, considering rotations and reflections as equivalent.

Cube coloring: Count ways to color the faces of a cube with kk colors, considering rotational symmetries.

Steps:

  1. Identify the symmetry group GG
  2. For each symmetry gg, count how many configurations are fixed by gg
  3. Apply Burnside's lemma

Example: Rotating a Square

For a square with 44 positions and kk colors:

  • Identity: k4k^4 configurations fixed
  • 90°90° rotation: kk configurations fixed (all same color in each "orbit")
  • 180°180° rotation: k2k^2 configurations fixed
  • 270°270° rotation: kk configurations fixed

Total distinct configurations:

14(k4+k+k2+k)=k4+2k+k24\frac{1}{4}(k^4 + k + k^2 + k) = \frac{k^4 + 2k + k^2}{4}

Grid Path Counting

Basic Grid Paths

From (0,0)(0,0) to (m,n)(m,n) using right and up steps:

(m+nm)\binom{m+n}{m}

Paths Avoiding Obstacles

Technique: Inclusion-exclusion or dynamic programming.

Single obstacle at (a,b)(a,b):

(m+nm)(a+ba)((ma)+(nb)ma)\binom{m+n}{m} - \binom{a+b}{a} \cdot \binom{(m-a)+(n-b)}{m-a}

Paths on a Grid with Boundaries

Rectangle with barrier: Use reflection principle.

Cycle lemma / André's reflection: For paths from (0,0)(0,0) to (n,n)(n,n) that stay weakly below y=xy = x: CnC_n

Diagonal Paths

Paths using diagonal steps: If diagonal (1,1)(1,1) is allowed along with (1,0)(1,0) and (0,1)(0,1):

Count using generating functions or recurrence relations based on last step.

Counting on Strings

Binary Strings

Binary strings of length nn: 2n2^n

Binary strings with exactly kk ones: (nk)\binom{n}{k}

Binary strings avoiding pattern: Use recurrence relations or generating functions.

Avoiding Consecutive Patterns

Binary strings of length nn with no two consecutive 1s:

Fn+2F_{n+2}

where FnF_n is the nn-th Fibonacci number.

Recurrence: an=an1+an2a_n = a_{n-1} + a_{n-2} with a1=2,a2=3a_1 = 2, a_2 = 3.

Strings with Forbidden Substrings

Technique: Inclusion-exclusion or automata/dynamic programming.

Example: Strings of length nn over alphabet Σ\Sigma avoiding substring ss:

  • Build a DFA/automaton that accepts strings containing ss
  • Use DP or transfer matrix method to count

Domino Tilings

Tiling a 2×n2 \times n Board

Problem: Count ways to tile a 2×n2 \times n board with 1×21 \times 2 dominoes.

Answer: Fn+1F_{n+1} (Fibonacci number)

Recurrence: Tn=Tn1+Tn2T_n = T_{n-1} + T_{n-2} with T0=1,T1=1T_0 = 1, T_1 = 1.

Intuition: Last column is either a vertical domino or two horizontal dominoes.

Tiling an m×nm \times n Board

For general m×nm \times n boards:

  • Use transfer matrix method
  • For small mm, recurrence relations work
  • For large boards, use advanced techniques (e.g., Kasteleyn's theorem for exact formula)

Aztec Diamond

The Aztec diamond of order nn has exactly 2n(n+1)/22^{n(n+1)/2} domino tilings.

Generating Functions

Ordinary Generating Functions (OGF)

For sequence a0,a1,a2,...a_0, a_1, a_2, ...:

A(x)=n=0anxnA(x) = \sum_{n=0}^{\infty} a_n x^n

Operations:

  • Addition: (A+B)(x)=A(x)+B(x)(A + B)(x) = A(x) + B(x)
  • Multiplication: (AB)(x)=A(x)B(x)(A \cdot B)(x) = A(x) \cdot B(x) gives convolution
  • Shift: xA(x)x A(x) shifts sequence by one

Common OGFs:

  • 11x=1+x+x2+\frac{1}{1-x} = 1 + x + x^2 + \cdots (geometric series)
  • 1(1x)k=n=0(n+k1k1)xn\frac{1}{(1-x)^k} = \sum_{n=0}^{\infty} \binom{n+k-1}{k-1} x^n (stars and bars)
  • (1+x)n=k=0n(nk)xk(1+x)^n = \sum_{k=0}^{n} \binom{n}{k} x^k (binomial)

Exponential Generating Functions (EGF)

For sequence a0,a1,a2,...a_0, a_1, a_2, ...:

A(x)=n=0anxnn!A(x) = \sum_{n=0}^{\infty} a_n \frac{x^n}{n!}

Use case: When order matters (permutations rather than combinations).

Example: Number of permutations of nn objects:

ex=n=0xnn!e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!}

corresponds to an=n!a_n = n!.

Advanced Counting Techniques

Recurrence Relations

Linear recurrence: an=c1an1+c2an2++ckanka_n = c_1 a_{n-1} + c_2 a_{n-2} + \cdots + c_k a_{n-k}

Solution technique:

  1. Find characteristic equation: xk=c1xk1+c2xk2++ckx^k = c_1 x^{k-1} + c_2 x^{k-2} + \cdots + c_k
  2. Solve for roots
  3. General solution is linear combination of rinr_i^n for each root rir_i

Example (Fibonacci): Fn=Fn1+Fn2F_n = F_{n-1} + F_{n-2} has characteristic equation x2=x+1x^2 = x + 1, giving:

Fn=ϕnψn5F_n = \frac{\phi^n - \psi^n}{\sqrt{5}}

where ϕ=1+52\phi = \frac{1+\sqrt{5}}{2} and ψ=152\psi = \frac{1-\sqrt{5}}{2}.

Bijective Proofs

Technique: Establish a one-to-one correspondence between two sets to show they have the same size.

Example: (nk)=(nnk)\binom{n}{k} = \binom{n}{n-k} by mapping a subset SS to its complement Sˉ\bar{S}.

Double Counting

Technique: Count the same quantity in two different ways to establish an identity.

Example: Handshaking lemma: vdeg(v)=2E\sum_{v} \deg(v) = 2|E|

Pigeonhole Principle

Basic Pigeonhole Principle

If nn pigeons are placed in kk holes and n>kn > k, then at least one hole contains more than one pigeon.

Generalized: If nn objects are placed in kk bins, at least one bin contains at least n/k\lceil n/k \rceil objects.

Applications

  • Ramsey theory (finding structure in large sets)
  • Proving existence of patterns
  • Subset sum problems

Example: Among any n+1n+1 integers, there exist two whose difference is divisible by nn.

Common Combinatorial Tricks

Trick 1: Complementary Counting

Count the complement and subtract:

Count(A)=TotalCount(Aˉ)\text{Count}(A) = \text{Total} - \text{Count}(\bar{A})

When to use: When the complement is easier to count.

Trick 2: Bijection Construction

Establish a one-to-one mapping between two sets.

Example: Counting Dyck paths ↔ valid parenthesizations.

Trick 3: Stars and Bars

Convert distribution problems to choosing positions for dividers.

When to use: Distributing identical objects into distinct bins.

Trick 4: Recursive Decomposition

Break problem into smaller subproblems based on choices.

Example: Catalan numbers—split based on where the first matching parenthesis closes.

Trick 5: Generating Function Manipulation

Encode the problem as a generating function and use algebra.

When to use: Recurrences, convolutions, coefficient extraction.

Trick 6: Symmetry Arguments

Use symmetry to reduce cases or simplify counting.

Example: Rotating/reflecting objects, choosing kk from nn vs. choosing nkn-k from nn.

Trick 7: Inclusion-Exclusion

Add and subtract overlapping sets to avoid double-counting.

When to use: At-least-one problems, derangements, forbidden configurations.

Trick 8: Reflection Principle

Reflect "bad" paths across a boundary to count them.

When to use: Lattice paths with barriers, ballot problems.

Trick 9: DP State Compression

For grid/path problems, track only necessary state.

Example: Domino tilings—track configuration of last column.

Trick 10: Cycle Index (Pólya Theory)

Extend Burnside's lemma with cycle structure.

When to use: Advanced symmetry problems, weighted counting.

Interview Problem Types

Type 1: Basic Counting (Permutations/Combinations)

GivenFindApproach
Selection or arrangement of distinct objectsNumber of waysUse (nr)\binom{n}{r} for selection, P(n,r)P(n,r) for arrangement

Type 2: Stars and Bars Problems

GivenFindApproach
Distributing identical objects into distinct binsNumber of distributionsUse (n+k1k1)\binom{n+k-1}{k-1} (bins can be empty) or (n1k1)\binom{n-1}{k-1} (bins non-empty)

Type 3: Lattice Path Counting

GivenFindApproach
Grid paths from (0,0)(0,0) to (m,n)(m,n) with constraintsNumber of valid pathsUse (m+nm)\binom{m+n}{m} baseline, reflection principle for barriers

Type 4: Catalan Number Applications

GivenFindApproach
Parenthesizations, Dyck paths, binary trees, triangulationsCount of valid structuresRecognize Catalan pattern: Cn=1n+1(2nn)C_n = \frac{1}{n+1}\binom{2n}{n}

Type 5: Inclusion-Exclusion Problems

GivenFindApproach
Count with forbidden overlaps (derangements, at-least-one)Objects satisfying constraintsUse Ai=AiAiAj+\|\bigcup A_i\| = \sum \|A_i\| - \sum \|A_i \cap A_j\| + \cdots

Type 6: String Counting with Constraints

GivenFindApproach
Strings over alphabet avoiding patternsNumber of valid stringsRecurrence relation, DP, or generating functions

Type 7: Symmetry and Burnside's Lemma

GivenFindApproach
Count distinct objects under symmetries (rotations/reflections)Number of equivalence classesApply Burnside: 1GgGXg\frac{1}{\|G\|} \sum_{g \in G} \|X^g\|

Type 8: Tiling and Domino Problems

GivenFindApproach
Tiling boards with dominoes or polyominoesNumber of tilingsRecurrence relations (often Fibonacci-like), transfer matrices

Type 9: Stirling Numbers and Partitions

GivenFindApproach
Partition nn objects into kk groups, distribute balls into binsCount under 12-fold wayUse Stirling S(n,k)S(n,k) or partition function p(n,k)p(n,k)

Type 10: Generating Function Problems

GivenFindApproach
Recurrence or sequence with generating functionClosed form or nn-th termSet up OGF/EGF, manipulate algebraically, extract coefficients

Common Pitfalls

Pitfall 1: Confusing Permutations and Combinations

Wrong: Using (nr)\binom{n}{r} when order matters

Check: Does rearranging the selection give a different outcome?

Pitfall 2: Forgetting the Division Principle

Wrong: Overcounting symmetric configurations

Example: Circular arrangements—divide by nn for rotations

Pitfall 3: Misapplying Stars and Bars

Wrong: Using wrong formula for "at least one in each bin"

Check: Empty bins allowed? Use (n+k1k1)\binom{n+k-1}{k-1}. Non-empty? Use (n1k1)\binom{n-1}{k-1}

Pitfall 4: Off-by-One Errors in Paths

Wrong: Miscounting steps or boundary conditions

Check: Verify small cases, ensure start and end points are correct

Pitfall 5: Incorrect Inclusion-Exclusion

Wrong: Missing terms or wrong signs in inclusion-exclusion

Check: Alternating signs, all subsets included

Pitfall 6: Not Recognizing Catalan Patterns

Wrong: Solving from scratch when pattern is Catalan

Check: Does problem involve balanced/nested structures, non-crossing partitions, or Dyck paths?

Quick Reference: Key Formulas

Permutations:

P(n,r)=n!(nr)!P(n,r) = \frac{n!}{(n-r)!}

Combinations:

(nr)=n!r!(nr)!\binom{n}{r} = \frac{n!}{r!(n-r)!}

Stars and Bars:

(n+k1k1)(bins can be empty)\binom{n+k-1}{k-1} \quad \text{(bins can be empty)}

(n1k1)(bins must be non-empty)\binom{n-1}{k-1} \quad \text{(bins must be non-empty)}

Catalan Numbers:

Cn=1n+1(2nn)C_n = \frac{1}{n+1}\binom{2n}{n}

Derangements:

Dn=n!k=0n(1)kk!n!eD_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!} \approx \frac{n!}{e}

Grid Paths:

(m+nm)from (0,0) to (m,n)\binom{m+n}{m} \quad \text{from } (0,0) \text{ to } (m,n)

Burnside's Lemma:

X/G=1GgGXg|X/G| = \frac{1}{|G|} \sum_{g \in G} |X^g|

Fibonacci Recurrence:

Fn=Fn1+Fn2,F0=0,F1=1F_n = F_{n-1} + F_{n-2}, \quad F_0 = 0, F_1 = 1

Stirling Numbers (2nd kind):

S(n,k)=kS(n1,k)+S(n1,k1)S(n,k) = k \cdot S(n-1,k) + S(n-1,k-1)

Practice Problem Categories

  • Combinations with repetition
  • Circular permutations
  • Multinomial coefficients
  • Partitions of integers
  • Bell numbers
  • Fibonacci variants
  • Pascal's triangle identities
  • Binomial coefficient identities
  • Lattice paths with multiple barriers
  • Non-crossing partitions
  • Parking functions
  • Young tableaux
  • Plane partitions
  • Schröder numbers
  • Motzkin numbers
  • Graph coloring under symmetry
  • Necklace and bracelet problems

On this page

Fundamental ConceptsBasic Counting PrinciplesPermutationsCombinationsStars and BarsEssential Identities and FormulasBinomial TheoremMultinomial TheoremVandermonde's IdentityHockey Stick IdentityThe 12-Fold WayStirling Numbers of the Second KindCatalan NumbersDefinitionApplications of Catalan NumbersDyck Paths and Lattice Path CountingDyck PathsGeneral Lattice Path CountingLattice Paths with BarriersBallot ProblemInclusion-Exclusion PrincipleGeneral FormulaDerangementsBurnside's Lemma (Pólya Enumeration)Burnside's LemmaCommon ApplicationsExample: Rotating a SquareGrid Path CountingBasic Grid PathsPaths Avoiding ObstaclesPaths on a Grid with BoundariesDiagonal PathsCounting on StringsBinary StringsAvoiding Consecutive PatternsStrings with Forbidden SubstringsDomino TilingsTiling a 2×n2 \times n BoardTiling an m×nm \times n BoardAztec DiamondGenerating FunctionsOrdinary Generating Functions (OGF)Exponential Generating Functions (EGF)Advanced Counting TechniquesRecurrence RelationsBijective ProofsDouble CountingPigeonhole PrincipleBasic Pigeonhole PrincipleApplicationsCommon Combinatorial TricksTrick 1: Complementary CountingTrick 2: Bijection ConstructionTrick 3: Stars and BarsTrick 4: Recursive DecompositionTrick 5: Generating Function ManipulationTrick 6: Symmetry ArgumentsTrick 7: Inclusion-ExclusionTrick 8: Reflection PrincipleTrick 9: DP State CompressionTrick 10: Cycle Index (Pólya Theory)Interview Problem TypesType 1: Basic Counting (Permutations/Combinations)Type 2: Stars and Bars ProblemsType 3: Lattice Path CountingType 4: Catalan Number ApplicationsType 5: Inclusion-Exclusion ProblemsType 6: String Counting with ConstraintsType 7: Symmetry and Burnside's LemmaType 8: Tiling and Domino ProblemsType 9: Stirling Numbers and PartitionsType 10: Generating Function ProblemsCommon PitfallsPitfall 1: Confusing Permutations and CombinationsPitfall 2: Forgetting the Division PrinciplePitfall 3: Misapplying Stars and BarsPitfall 4: Off-by-One Errors in PathsPitfall 5: Incorrect Inclusion-ExclusionPitfall 6: Not Recognizing Catalan PatternsQuick Reference: Key FormulasPractice Problem Categories