Amazon.com Interview Question
1,580 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer at Amazon.com:
You are given 1000 containers of water with exactly one container containing poison. You can use pigs to test which container contains poison. The conditions are that: A pig drinking the poisoned water woudl die exactly after 1 hour and that a pig could be used for sampling multiple containers. Assume that the pig takes 0 time to drink water from any number of containers. What is the minimum number of pigs would you use to identify the poisoned container within 1 hour.
| Tags: | brain teaser, phone See more , See less 8 |
See more for this Amazon.com Software Development Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (4)
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



10 of 10 people found this helpful
by Interview Candidate:
This problem can be viewed as a mapping between bits and container.i.e
0000000000 -> Container 1 (No pig drinks from this container)
0000000001 -> Container 2 (Pig 1 drinks)
0000000010 -> Container 3 (Pig 2 Drinks)
0000000011 -> Container 4 (Pigs 1 and 2 drinks from this container)
0000000100 -> Container 5 (pig 3 drinks from this container)
....
Every container has a unique combination of pigs that sample it. Therefore just examining which combination
of pigs die, one can infer which container holds the poison.