I think the question is is not rigorous enough...

  • 0

    The question says, "every element appears twice except for one", what if THAT ONE appears for even-number times, like 4 times. Then you can't solve this by XOR operation. Isn't it?

  • 0

    The problem states:

    Given an array of integers, every element appears twice except for one. Find that single one.

    While your interpretation of the question appears to interpret "single" as a single value, there is a slight problem with your thought. Assume there is a trio or quad of the values. Then the statement "every value in the array appears twice except one" would work under your interpretation.

    However, the question asks for the one element. If there is a trio or more, then that one value appears in three or more elements, so there is no single element that does not appear twice. It is a slight difference, but it does restrict the target value to a singleton.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.