Python Strange Solution (XOR)


  • 0
    P

    I find if use this method, the array can not be sorted..

        def singleNonDuplicate(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            val = 0
            for each in nums:
                val ^= each
            return val
    

Log in to reply
 

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