Combinatorics

Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures.

Combinatorics studies methods for counting combinations of objects. Usually, the goal is to find a way to count the combinations efficiently without generating each combination separately.

Competitive Programming

Combinatorics studies methods for counting combinations of objects. Usually, the goal is to find a way to count the combinations efficiently without generating each combination separately.

I always get confused about this topic, know when to use different formulas.

  • Number of Permutations use
    • This is when you use all the elements and just swap their positions
    • If it’s a subgroup, see Permutations and Combinations
  • Number of different Subsets use
    • For each element, you can either choose to include them or not
    • because we don’t include the empty subset
  • Number of subarrays (contiguous substrings) use
    • Even less because there is the consecutive constraint
    • This is just the Summation, you have choices starting from the first element, starting from the second element, and choice starting from the last array
      • Do not confused with when you choose , that is is from

OMG, this series is insanely good. https://www.youtube.com/watch?v=XPPYYM6WCuE&list=PLmdFyQYShrjfPLdHQxuNWvh2ct666Na3z&index=2

Note

When repetition is allowed, you can just exponentiate it When repetition is not allowed, you need to use factorial

Topics