its really fantastic!this is a trick hah
Kudos, quite a nice work!
yes, XOR is commutative
so N1^N2^N3 = N1^N3^N2=N2^N3^N1=N2^N1^N3=......
But then you are using extra memory ;)
@caikehe Very delicate solution using the xor operation, thank you!
How can this be done in python, this code malfunctions for [1,0,1] test case in python.
If take "i" as consider, this is no extra space :)
The XOR operation is one single machine operation, it doesn't matter the length of binary number.
Also, in Big O(), O(n) is equivalent as O(x*n), the complexity remains linear which is what we care most of the time.
No one has replied
this is so coooool!
Brilliant!!! But who can tell me the space complexity of the code? Thx!
I think your code works now on the current judge system~
excellent. two xor operations cancel each other.
This will be valuable as functional programming languages becoming increasing popular in the job marketing.
@monil1511gmail.com When do the XOR operation between same numbers, the result is 0. For example, "1101" XOR "1101", the result is "0000". Then in this problem, the paired values are eliminated by XOR, and the single value will be left.
Hi @MissMary , I did a small modification which based on your code
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.