You are one of 20 prisoners on death row with the execution date set for tomorrow. Your king is a ruthless man who likes to toy with his people’s miseries. He comes to your cell today and tells you:
“I’m gonna give you prisoners a chance to go free tomorrow. You will all stand in a row (queue) before the executioner and we will put a hat on your head, either a red or a black one. Of course you will not be able to see the color of your own hat; you will only be able to see the prisoners in front of you with their hats on; you will not be allowed to look back or communicate together in any way (talking, touching…..).
The prisoner in the back will be able to see the 19 prisoners in front of him. The one in front of him will be able to see 18…
Starting with the last person in the row, the one who can see everybody in front of him, he will be asked a simple question: WHAT IS THE COLOR OF YOUR HAT?
He will be only allowed to answer “BLACK” or “RED”. If he says anything else you will ALL be executed immediately.
If he guesses the right color of the hat on his head he is set free, otherwise he is put to death. And we move on to the one in front of him and ask him the same question and so on…
Well, good luck tomorrow, HA HA HA HA HA HA!”
Now since you all can communicate freely during the night, can you find a way to guarantee the freedom of some prisoners tomorrow? How many?
Find Answer here
You are one of the 125 candidates that have been shortlisted to appear for an interview for a job in the company Amgon that pays five lakhs per month. Mr. Donny, a representative of Amgon is in the interviewing panel and he is responsible to select only one candidate for the job. He gives each candidate the same task in which he gives three dice each to every candidate. No marking of any kind has been done on any of the six faces of the dice. He tells them to write one letter each on all the faces of the three dice so that the top faces of the dice can show first three letters of all the months in the year. Can you complete the task and get the job?
Find Answer here
Given weights and values of n gift items. We have a box of capacity W. Find a solution such that the total value of gifts in the box is maximum.
In this Problem, we have two integer arrays value[0,1,2,…,n-1] and weight[0,1,2,3…,n-1],it represents the values and weights associated with n items resp. Given an integer W which represents the total capacity of the box. Write a Program to find the maximum value V which is the sum of the subset of values (value) such that the sum of the weight of this subset is smaller than or equal to W.
We either have to pick the complete gift item or don’t pick it.
Also known as 0-1 Knapsack Problem because we cannot split the item mentioned. Either we don’t pick the item (i.e 0) or pick the complete item (i.e 1).
Find Solution here