The ballot problem asks for the probability that candidate A is always ahead of candidate B during a tallying process if they respectively end up with and votes where . For example if there are 3 ways in which the three votes are counted (AAB, ABA, BAA) but the only favourable outcome in which A remains ahead throughout is occurs if the tally appears as AAB. Hence the probability A remains ahead is 1/3.

If there are no restrictions, the number of ways the votes are tallied is the binomial coefficient . The number of favourable outcomes (the numerator of the desired probability) in which A remains ahead can counted recursively in a similar way to Pascal’s triangle (each number the sum of the two neighbours above it) except no number may appear to the left of the vertical midline, as illustrated below. For example, the second element of the fifth row (3) corresponds to the case (AAAB, AABA, ABAA). More generally, dividing into the cases where the final vote is A or B, the number of ways in which A remains ahead of B is equal to where if . This sequence appears as A008313 in the OEIS and is the reversed form of Catalan’s triangle.

A way of generating the general term is making use of a beautiful reflection principle that gives a 1-1 correspondence between the number of tallies leading to a tie at some point and the number of tallies in which the first vote goes to candidate B: simply interchange A with B for all votes up to and including that tie. This amounts to reflecting the random walk about the midline, as illustrated below with the blue path corresponding to ABAA and the the red path BAAA.

Since , the probability candidate A always leads is 1 minus the probability the sequence ties at some point. But the bijection above shows an equal number of these start with A and with B, so our desired probability is

The numbers in the triangle are also formed by differences of adjacent entries of Pascal’s triangle, namely row p+q has terms of the form

This can be interpreted as the number of unrestricted sequences with p As and q Bs of length (p+q) that start with A minus the corresponding number that start with B, again following from the reflection principle.

As an aside, looking at the bottom row above we see , or equivalently

Finally we note that the Catalan numbers arise from the following parts of the triangle above:

- as entries in the first column (counting Dyck paths)
- as the sum of squares of each row
- as the sum of entries in NE-SW diagonals

Catalan’s triangle can be generalised to a trapezium in which we count the number of strings consisting of n As and k Bs such that in every initial segment of the string the number of Bs does not exceed the number of As by m or more.