Inclusion-Exclusion Principle
See the complete article on my own blog https://dyingdown.github.io/2019/08/15/Inclusion-Exclusion-Principle/
In combinatorics (combinatorial mathematics), the inclusion–exclusion principle is a counting technique which generalizes the familiar method of obtaining the number of elements in the union of two finite sets; – From Wikipedia
[外链图片转存失败(img-i1D8ihUF-1567835680066)(https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Inclusion-exclusion.svg/220px-Inclusion-exclusion.svg.png)]
Example: Set A and B
∣ A ∪ B ∣ = ∣ A ∣ + ∣ B ∣ − ∣ A ∩ B ∣ |A \cup B| = |A|+|B|-|A \cap B| ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣
Set A, B and C
∣ A ∪ B ∪ C ∣ = ∣ A ∣ + ∣ B ∣ + ∣ C ∣