Solution
Let us try to understand the puzzle:
We know that Bob is stuck on an island and is sick and needs medicine. Alice has medicine, but she is on another island. The only mode of transportation of goods between those two can be done by Eve by a boat. The boat has a chest that can be locked by multiple locks. Eve will steal the chest if it is not locked. Bob and Alice have their own padlocks with their respective keys. Alice and Bob can close the chest by using one lock or both their locks. We have to determine whether Alice can send the medicine to Bob and the minimum number of trips if it is possible.

A chest that can be locked by multiple padlocks
At the start of the trip, Alice has the medicine and her lock (let us call if lock A) while Bob has his lock (lock B).
Trip 1:
Alice puts the medicine in the chest and locks it with lock A and keeps its key with her. Eve transports the medicine locked in the chest to Bob. Bob cannot open the chest.
Trip 2:
Now Bob locks the chest with his lock B. The chest is locked by both locks. Eve transports the chest back to Alice.
Trip 3:
Alice opens lock A with her key, and now Eve transports the chest back to Bob. The chest is still locked by lock B.
Finally, Bob opens lock B with his key and retrieves the medicine.
Answer: 3 trips
This is the minimum number of trips needed to transport the medicine without being stolen.
Check out this problem - 8 Queens Problem
Frequently Asked Questions
How should we solve the puzzles during the interview?
Think about the problem and try to understand the question. Ask for clarifications if you feel that you do not understand the puzzle. Getting the right answer is not as important as your approach. Always explain your approach while answering.
How do we prepare the puzzles for the interview?
The best approach is to practice different puzzles and solve the previously asked puzzles.
Should we always reach the correct answer to the puzzle during the interview?
You should focus on your approach and your ability to convey it to the interviewer. Sometimes, you may not be able to reach the correct answer, but if your approach is right, it does not matter much.
Conclusion
This article solved a famous puzzle called the medicine chest on a boat puzzle. You can solve any puzzle asked in your interview if you keep practicing these types of puzzles.
Recommended Readings:
Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.
Also check out some of the Guided Paths on topics such as Interview Puzzles, Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.