Adobe Interview Question
Developer Program EngineersCountry: India
Interview Type: In-Person
I side with this solution. Why does everyone always want to use state machines for these sorts of problems? I mean, what if your requirements change and you need to do it mod 77 now? Better to write general code if you can.
It is giving right ans . Check it again . 39=(starting_bit)100111(end_bit)
1 == rem=1
10 == rem=2
100 == rem=1
1001 == rem=0
10011 == rem=1
100111 == rem=0
Hence , proved
at any instance count the no of 1s .if the count is 2,the number is divisible by 3 otherwise not.
At any instance instead, Count the number of one's, if its even, the number is divisible by 3.
remainder=0
- Shobhit July 04, 2012remainder=(remainder*2+incoming_bit)%3