You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this approach, we use the fact that XORing a number with itself results in 0. By XORing all the indices and the elements of the input array, and finally XORing the result with the length of the array, the missing number will remain.
29
+
30
+
This updated code has a time complexity of O(n), as it iterates through the input array once. The space complexity remains O(1) since it does not use any additional data structures that grow with the input size.
0 commit comments