Guaranteed Repeats by the Pigeonhole Principle

Coding
Combinatorial Reasoning
Easy
An array of n+1 integers contains values only from {1,...,n}. What principle guarantees at least one repeated value?
Hint 1

Think of the n possible values as boxes and the n+1 array entries as items placed into those boxes.

Hint 2

If more items than boxes are placed, at least one box must receive more than one item.

Show worked solution
  1. 1. Map values to pigeonholes

    Treat each of the possible values as a box, and place each of the array entries into the box matching its value.

  2. 2. Apply the principle

    Since there are more items () than boxes (), the pigeonhole principle guarantees some box receives at least two items, meaning some value repeats.

Answer: The pigeonhole principle.

Related roles: Browse quant jobs

Related problems