How would you optimize this algorithm to handle a 10x increase in input size?
Implement the optimized version for duplicate detection. Given a list of integers, return True if any value appears more than once, otherwise return False. The function must preserve correctness as the input grows substantially.
Input: a list of integers. Output: a boolean.
def contains_duplicate(nums):