Problems > Ordinal Numbers > Editorial

Ordinal Numbers — Solution & Editorial

Back to the Problem

The teens (11–13 mod 100) always take th; otherwise the last digit decides st/nd/rd/th.

Complexity: O(1)

Watch out: 111th, not 111st — the mod-100 teens rule overrides the last digit.