Bit Manipulation - Find the Missing Number
In the following Python code to find the missing number using XOR, which line causes incorrect results when the missing number is n?
def find_missing(nums):
n = len(nums)
xor_val = 0
for i in range(n):
xor_val ^= nums[i]
for i in range(n):
xor_val ^= i
return xor_val
