Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
First of all it is using logic gates. In this case, we are using the bitwise or.
So:
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
and for example if our array of numbers is [5, 3, 2, 5, 2].
Now if we iterate through this array we can see that if we bitwise all the numbers we get the number that isnt repeated as the same number will cancel out each other and equal 0
5 ^ 5 -> 1 0 1 ^ 1 0 1 = 0 0 0
If they are the same value, they equal 0 and if they are different values they equal 1. despite weather or not the two values are 1's or 0's.
Now when we iterate through the array
1 0 1 ^ 0 1 1 = 1 1 0
1 1 0 ^ 0 1 0 = 1 0 0
1 0 0 ^ 1 0 1 = 0 0 1
0 0 1 ^ 0 1 0 = 0 1 1 which is equal to 3.
This comment is hidden because it contains spoiler information about the solution
hey bro, can you explain this please , because I am a kind of lost