Amazon Interview Question
Software Engineer / DevelopersCountry: India
Follow a similar approach as given in below link for code word generation
Means for a code word of length n-bits a we have to call a function similar to next.
stackoverflow.com/questions/4633584/algorithm-to-generate-all-possible-arrays-of-ones-and-zeros-of-a-given-length
But for closure property we have to make a separate API.
We already have the binary code words.
So first we need to cluster them according to their size in respective buckets(appropriate container).
Then we should look into each container and check to see if it contains any subspaces.
We start with hashing all elements in each container then according to the size of container we check the starting criteria that it should have 00...00 of required length and if it is not their then we can discard the whole container.
If we have 00....00 of required length then we should add the next element in the container to this element and check if the resulting codeword is present in the container for the first instance it will be but for there on keep checking the same each time.
I guess this solve the problems.
Let me know your comments on the same.
All the codewords are of same length. I think you have not understood the problem well.
can anyone elaborate the problem?
- duke87 May 20, 2013