Gates of Heaven

Amanda dies and reaches at the gate of heaven.

She has three doors in front of her out of which only one of them leads to heaven.
Out of the other two gates, one leads to hell for one day and then back to the gate and one leads to hell for two days and then back to the gate.

If she chooses one of these two gates, the gates are shuffled when she returns back.

How long is Amanda expected to take to reach heaven?
Output the number of days.

Answer is a integer. Just put the number without any decimal places if its an integer. If the answer is Infinity, output Infinity.

Feel free to get in touch with us if you have any questions

Hints
  • Complete Solution
1864 successful submissions.
Click here to jump start your coding interview preparation