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.
why you allocating buffer with sizeof(char*)?
you don't storing pointers, just chars lol
also casting malloc result isn't good practice
Can you please explain to me why does xoring the bits work?
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
genial
https://www.tutorialspoint.com/cprogramming/c_strings.htm
https://www.geeksforgeeks.org/strings-in-c-2/
https://www.w3schools.in/c-tutorial/strings/
I'm not a C guy, but as far as I understand, you allocate some space first, then return it, even if it's empty. I think your allocation calculation numbers aren't entirely correct.
how do you do that please ? and thanks for your response
This is where it crashes. That's not how you return a freeable pointer.
This comment is hidden because it contains spoiler information about the solution
You should import math library
This comment is hidden because it contains spoiler information about the solution
Please can you explain me this ?
can you explain this please ?