I failed on an input of [2,2,2,2,2]. According the the problem definition this is an invalid test case:

"Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only ONE duplicate number, find the duplicate one."