'Contains Duplicate' Algorithm Explained