Google Interview Question | Bit Manipulation | Solution With Code | Interview Bit Problem

preview_player
Показать описание
Hi,

This is the eighth video of our playlist named "InterviewBit Problems and Solutions" named as "Single Number II".

#gocode
#google
#interview
Рекомендации по теме
Комментарии
Автор

I have searched a lot for good explanation...finally i got it...
Thanks bro.

idk_
Автор

Good explanation ! Found this video really helpful !

harinijeyaraman
Автор

Very nice and straightforward explanation. Thanks!

Mauryarohit
Автор

Hey man
Help me out
I tried your code
But if I change the 12th line of your code from '!=0' to '==1', the code stops working
If it's binary, it should be either 0 or 1 right?
So I should be able to do A[j] & (1<<i) == 1 as well
But it doesn't work for some reason and I am not able to figure out why it doesn't work

AvinashSingh-kloz
Автор

Will this also work with negative numbers, e.g. what if the input is
[-2, -2, 1, 1, -3, 1, -3, -3, -4, -2]?

subzeroOrkut
Автор

Please correct me if I'm wrong, like if the number that appears once and the number which appears multiple times has bit set to 1 then it will produce two output which is not divisible by 3 example
A = [5, 3, 3, 3]
binaryA = [0101, 0011, 0011, 0011]


Sum of First bits%3 = (1+1+1+1)%3 = 1
Sum of Second bits%3 = (1+1+1+0)%3 = 0
Sum of Third bits%3 = (0+0+0+1)%3 = 1


Now we have 2 numbers that are not divisible by 3 ?
Please correct me if i am wrong

mukulbakshi
Автор

If you haven't had fully understood how to solve the problem till now.
Check out my video on this question
Let me know your comments.

AlgorithmsMadeEasy
Автор

Please the audio is not good .. the sound is little too harsh for the ears .. but good video content keep going

MegaPaloma
Автор

This is not O(n). The actual complexity is O(n*log(max_value))... because you have to check each bit O(n) times...and at max the bits are log(max_value)

vatsalsonigara
welcome to shbcf.ru