Ordinal Numbers — Solution & Editorial
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.
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.